A very important difference between Windows NT and Windows 9x is that Windows NT offers a number of powerful service (services). These service can be started with NT start, also can let the user start through the Control Panel, also can be WIN32 application to stop. These service can be performed even without the user logging on to the system. Many FTP, WWW servers and databases exist on the NT in the form of service, thus realizing unattended. Even the latest version of the "hacker" program Back Orifice 2000 also in the form of service in NT hiding. Because of the complexity of service programming, many developers want to develop their own service but are often discouraged. In view of this, we will construct a new service from beginning to end, so that readers can easily have their own service if they add their own code to the place noted in the program. Before you write a service, let's introduce several important functions:
1. Sc_handle OpenSCManager (LPCTSTR lpmachinename,
LPCTSTR Lpdatabasename, DWORD dwdesiredaccess)
OpenSCManager function to open the service control on the specified computer
Manager database. Where the parameter lpmachinename specifies the computer name and, if it is empty, is specified as a native. LPDATABASENAME specifies that the Service Control Manager database name you want to open is null by default. dwDesiredAccess Specify the permissions for the operation, you can take one of the following values:
Sc_manager_all_access//All rights
Sc_manager_connect//Allow connection to service control MANAGER database
Sc_manager_create_service//allows creating a service object and adding it to the database
Sc_manager_enumerate_service//Allow enumeration of SERVICE in database
Sc_manager_lock//Allow lock database
Sc_manager_query_lock_status//Allow query database for blocking information
Function success returns a point to the Service Control Manager