I. NT service programs
The so-called NT Service is actually a process that can automatically start with a certain identity when the system starts. Such as FTP server, HTTP server, and offline printing are provided in the form of NT services. This is actually similar to the Unix root daemon process. In summary, the NT Service has the following features:
1. It can be started automatically without interactive startup. This is an important feature for servers. Of course, you can decide whether the service is self-started or even block a service.
2. the NT Service has no user interface, which is basically similar to a DOS program. Because the NT Service must run for a long time, you do not want to have your own interface like the common win32 process. However, the NT Service can interact with the user interface, which is a special service process. You can view the service process through the task manager of NT.
3. the NT Service is managed through the SCM interface. The SCM interface functions are required for installation, start, stop, and removal. The service controller of the Control Panel uses the SCM interface to manage all services in the system. In addition, there are some program commands that can control the service, such as 、SCM.exe, such as net.exe, Server Manager, and so on.
4. These processes run in a certain identity to facilitate access to server resources. Generally, the LocalSystem account in the domain is used to run the program. This account has full access permissions to most resources on the machine (unless otherwise prohibited), which ensures that the service program is "powerful ". However, some services run with special accounts. You can also set a service account.
5. the system automatically runs in the thread mode. Generally, it only occupies more system resources. This is different from common processes. If the thread mode is not used, generally, processes consume the entire CPU resource. Generally, tasks that need to exist from time to time and do not consume too much resources are most suitable for Service implementation.
Ii. Service controls
C/C ++ is generally used to compile NT services. VC6 uses the ATL Wizard to provide a basic service framework. The specific implementation steps are: File à New... À atl com AppWizard à service à Finish. But using VC to compile NT services requires too much code, which also means too much debugging and maintenance. In fact, the NT Service cannot be written only by C/C ++. In fact, it can be implemented by any language that can implement the features of the previous section, including VB.