There is such an application that is available for a variety of users (including local users and remote users),
With the ability to manage the user authorization level, and regardless of whether the user is physically, it is running the application
Both the order of the order can be implemented normally, which is the so-called service.
(1) Basic knowledge of services
Question 1. What is a service? What is its characteristics?
In NT / 2000, the service is a program that is subject to operating system. A service is first is one
Win32 executable, if you want to write a complete and powerful service, you need to be familiar with the dynamic connection library
(DLLS), structural exception handling, memory map file, virtual memory, device I / O, thread and synchronization,
Unicode and other application interfaces provided by the WinAPI function. Of course, this article is discussed only to establish one.
Can be installed, run, start, stopped without any other functions, so there is no need for the above knowledge
You can continue to look at it, I will understand the knowledge required by this article in the process.
The second question is that a service will never require a user interface. Most services will run in those
Lock in some dark, winter warm summer cool small houses on the powerful server, even if there is a user interface
No one can see it. If the service provides any user interface such as a message box, then the user misses these
The possibility of messages is extremely high, so the service program usually writes in the form of a console program, entry point
The function is main () instead of WinMain ().
Some people may have questions: how to set up without a user interface, how to manage a service? How to open
Start, stop it? How to make a warning or error message, how to report statistics on its implementation
data? The answer to these issues is that the service can be managed by remote management, and Windows NT / 2000 provides a lot.
Management tools that allow for other computers on the network to perform services on a machine
management. For example, the "Console" program (MMC.exe) in Windows 2000, use it "management single
Yuan "can manage the service on this unit or other machine.
Question 2. Service security ...
If you want to write a service, you must be familiar with the security mechanism of WIN NT / 2000, in the above operating system
All security is based on users. In other words - process, thread, file, registry key, letter
Number, events, etc. are all users. When a process is generated, it is executed in one
A user's context (Context), this user account may be in this unit, or other other in the network
On the machine, or in a special account: system account - the context of the system account
If a process is executing under a user account, then this process has this user at the same time.
All access rights you can have, whether in this unit or a network. The system account is a special account
No., it is used to identify the system itself, and any process running under this account has the system.
Access permissions, but the system account cannot be used in the domain, unable to access network resources ...
The service is also the Win32 executable, which also needs to be executed in a context, usually service is
The system account is running, but it can also be selected under a user account according to the situation.
Therefore, the permissions of the corresponding access resource are obtained.
Question 3. Three components of the service
A service consists of three parts, the first part is Service Control Manager (SCM). Each
Windows NT / 2000 systems have a SCM, SCM is stored in Service.exe, started in Windows
It will be automatically run when it is accompanied by the startup and shutdown of the operating system. This process is
Trust, and provide a unified, secure means to control service. It is actually an RPCServer, so we can install and manage services remotely, but this is not within the scope of this article.
The SCM contains a database that stores information that has been installed and the driver, which can be unified via SCM.
Safe management of this information, so the installation process of a service program is written in your own information.
This database.
The second part is the service itself. A service has necessary to receive signals and orders from SCM
Special code, and can pass it back to SCM after processing.
The third part is the last part, is a Service Control Dispatcher (SCP).
It is a user interface that allows users to start, stop, suspend, continue, and control one or more
Win32 application installed on a computer. The role of SCP is to communicate with SCM, Windows
"Service" in the 2000 management tool is a typical SCP.
In these three components, the user is most likely to write the service itself, and it may also have to write one.
As an SCP and SCM communication with its accompanying client program, this article only discusses the design and implementation of one
Services, about how to implement an SCP, introduced in other articles in future.
Question 4. How to start design services
Remember that the entry point function I mentioned earlier is generally main ()? A service owns
Very important three functions, the first is the entry point function, actually using WinMain as an entry point function
Nothing, although the service should not have a user interface, but there are few exceptions,
This is why the options in the drawings below.
Because of the information interaction with the user desktop, the service program sometimes uses WinMain () as an entry point.
function.
The entrance function is responsible for initializing the entire process, executed by the main thread in this process. This means it
Apply to all services in this executable. You know, you can include multiple people in an executable file.
Service makes it more effective. The main process notifies that SCM contains several services in the executable, and
Give the address of each service's serviceMain callback function. Once the executable
All services in the inside have stopped running, and the main thread clears the entire process before the process terminates.
The second very important function is Servicemain, I have seen some examples of themselves
The entry point function of the service is fixed to be servicemain, in fact, there is no rule to live
Name, any function can be used as a service entry point function as long as the following forms can be used.
Void WinAPI Servicemain (DWord dwargc, // parameter number LPTSTR * LPSZARGV / / parameter string);
This function is called by the operating system and performs code that can complete the service. A dedicated thread execution
The servicemain function for each service, pay attention to the service instead of the service, because each service
There is also a servicemain function that is the only corresponding to yourself, and you can use the management tool.
"Services" to check the services that come into Win2000, it will find that many services are
Service.exe is provided separately. When the main thread calls Win32 functions StartServiceCtrldispatcher
At the time, SCM generates a thread for each service in this process. Every one in these threads
With its corresponding service servicemain function, this is why the service is always multi-threaded.
- A executable only one service will have a main thread, other thread execution service itself
.
The third is the last important function is CtrlHandler, which must have the following prototype
:
Void WinAPI CtrlHandler (DWord FDWControl // Control Command) Like Servicemain, CtrlHandler is also a callback function, and the user must serve it.
Each service writes a separate CtrlHandler function in the program, so if there is a program contains two
Service, then it is at least 5 different functions: as the entry point, main () or WinMain (),
Servicemain function and ctrlhandler function for the first service, as well as the second service
Servicemain function and ctrlhandler function.
SCM calls a service CtrlHandler function to change the status of this service. For example, when a certain
The administrator uses the "service" in the management tool to try to stop your service, your service
The CtrlHandler function will receive a service_control_stop notification. Ctrlhandler function is responsible
Perform all the code required to stop the service. Because it is the main thread of the process, all CtrlHandler letters
Number, thus try to optimize the code of your CtrlHandler function, so that it runs fast enough to
The CtrlHandler function of other services in the same process can receive them within the appropriate time.
Notice. And based on the above reasons, your CtrlHandler function must be able to communicate the state
Send to the service thread, this transfer process does not have a fixed method, depending on your service.
(2) Above the in-depth discussion of services
The last chapter is actually a general introduction, and the following is the real detail. Enter a letter
In the number of servicemain's initialization, accurate point is initialized
SERVICE_TABLE_ENTRY structure array, this structure records the above in this service
There is a service name and service entry point function, the following is an example of service_table_entry:
Service_table_entry service_table_entry [] = {{"myftpd", ftpdmain}, {"myhttpd", httpserv}, {null, null},};
The first member represents the name of the service, the second member is the address of the servicemain callback function,
The above service program has three service_table_entry elements because of two services.
Two for services, the last NULL indicates the end of the array.
Next, the address of this array is passed to the StartServiceCtrldispatcher function:
Bool StartServiceCtrlDispatcher (lpservice_table_entry lpservicestarttable)
This Win32 function indicates how the process of executable file notifies that the SCM is included in this process.
. Just like the last chapter, StartServiceCtrldispatcher is passed to each of its
Non-empty elements in the group produce a new thread, each process begins to perform in the array element
The servicemain function indicated by lpservicestartTable.
After the SCM launches a service, it will wait for the main thread of the program.
StartServiceCtrldispatcher. If that function is not called within two minutes, SCM will
It is considered that this service has problems and calls TerminateProcess to kill this process. This requires you
The main thread is as fast as possible to call StartServiceCtrldispatcher.
The StartServiceCtrlDispatcher function does not return immediately, but it will reside in one cycle.
Circle. When it is in the cycle, StartServiceCtrldispatcher hangs yourself and waits one of the following two events. First, if the SCM is going to send a control notification to run within this process
This thread will be activated when a service. When the control notification arrives, the thread is activated and called the corresponding
Ctrlhandler function of the service. CtrlHandler function handles this service control notification and returns to
StartServiceCtrldispatcher. StartServiceCtrlDispatcher loops back again
Suspend himself.
Second, if a service in the service thread is aborted, this thread will also be activated. under these circumstances
The process will be running in its number of services in it. If the number of services is zero,
StartServiceCtrlDispatcher will return to the entry point function so that any and progress can be performed
Related to clear work and end the process. If there is also a service run, even if it is just a service,
StartServiceCtrlDispatcher will continue to loop and continue to wait for other control notifications or
The remaining service thread is aborted.
The above content is about the entry point function, the content below is about the servicemain function.
. Still remember the prototype of the previous servicemain function? But actually a servicemain letter
The number is usually ignored two parameters passed to it because the service is generally not very transmitted. Set up a service
The best way is to set up a registry, general service in HKEY_LOCAL_MACHINE / System / CurrentControlSet / Service / ServiceName / Parame
Under the Terson key, the serviceName here is the name of the service. In fact, it may be written
A client application goes on the background setting of the service, this client application is noted
In the app, the service is read. When an external application has changed a service in a run
When setting data, this service can be accepted by the RegNotifyChangeKeyValue function.
Notification, this allows the service to reset yourself quickly.
As mentioned earlier, StartServiceCtrldispatcher is non-empty in each of its arrays.
A new thread is generated. Next, what is a servicemain? Original in MSDN
The text is said: The servicemain function shouth immedierately call the
RegisterServiceCtrlHandler Function to Specify A Handler Function TO
Handle Control Requests. Next, IT Should Call The SetServiceStatus
Function to send status information to the service control manager.
what? Because after the start of the service request, if the service is not completed within a certain time
After the SCM will believe that the service startup has failed, the length of this time is 80 seconds in WIN NT 4.0.
Unknown in Win2000 ...
Based on the above reasons, ServiceMain should quickly complete their own work, first of all, it is essential two
The item works, the first item is to call the RegisterServiceCtrlHandler function to inform SCM.
The address of the CtrlHandler callback function:
Service_Status_Handle RegisterServiceCtrlHandler (LPCTSTR LPSERVICENAME, // Service Name LPHANDLER_FUNCTION LPHANDLERPROC // CtrlHandler function address) The first parameter indicates which service you are being created, the second paragraph
The number is the address of the CtrlHandler function. LPSERVICENAME must be in Service_Table_ENTRY
The name of the service that is initialized is matched. RegisterServiceCtrlHandler returns one
Service_status_handle, this is a 32-bit handle. SCM uses it to uniquely determine this service.
When this service needs to report it to the SCM at the time, this handle must be passed.
Its Win32 function. Note: This handle is different from most of the other handles, you don't need to close it.
SCM requires the thread of the servicemain function to call within a second
The RegisterServiceCtrlHandler function, otherwise SCM will think that the service has failed. But in this situation
In case, SCM does not terminate service, but this service will not be launched in NT 4, and it will return one
Incorrect error message, this is amended in Windows 2000.
After the RegisterServiceCtrlHandler function returns, the servicemain thread tells immediately
The SCM service is continuing to initialize. The specific method is to pass the SETSERVICESTATUS function.
Service_status data structure.
Bool SetServiceStatus (Service_Status_Handle Hservice, // Service Handle Service_Status LPServiceStatus // Service_Status structure) Address)
This function requires it to pass the handle of the service (just call
RegisterServiceCtrlHandler gets), and an initialized service_status structure
site:
typedef struct _SERVICE_STATUS {DWORD dwServiceType; DWORD dwCurrentState; DWORD dwControlsAccepted; DWORD dwWin32ExitCode; DWORD dwServiceSpecificExitCode; DWORD dwCheckPoint; DWORD dwWaitHint;} SERVICE_STATUS, * LPSERVICE_STATUS;
The service_status structure contains seven members that reflect the current state of the service. All these
The member must be in the correct settings before this structure is passed to SetServiceStatus.
Members DWServiceType indicate the type of service executable. If you are only in your executable
There is a single service, set this member to service_win32_oen_process; if necessary
If there are multiple services, set it to service_win32_share_process. In addition to these two signs
In addition, if your service needs to interact with the desktop (of course, it is not recommended to do this), you must use "OR" operation.
The symbol is attached to service_interactive_process. The value of this member is in your service life.
Never change.
Members dwcurrentState are the most important members in this structure, which will tell SCM your service
Current state. In order to report the service, it is still initialized, and this member should be set to
Service_start_pending. In the future, the CtrlHandler function will be specifically explained.
Possible value.
Members dwcontrolsaccepted indicates what kind of control notification is willing to accept. If you are allowed
A SCP is paused / continuing service, set it to service_accept_pause_continue. a lot of
Service does not support pause or continue, you must decide whether it is available in the service. If you allow one
SCP will stop service, set it to service_accept_stop. If the service is to be on the operating system
When it is closed, it is notified to set it for service_accept_shutdown to receive the expected result.
These marks can be combined with the "OR" operator.
Members dwwin32exitcode and dwservicespecifiXitcode are allowed to report errors
Key, if you want to serve a Win32 error code (predefined in WineError.h), it
Set dwwin32exitcode as required code. A service can also report itself, no
Map into a predefined Win32 error code. For this,
DWIN32EXITCODE is set to ERROR_SERVICE_SPECICICIC_ERROR, then set a member
DWServicesPecIfficeXitcode is an error code that is unique to service. When the service is running normally, it is not wrong.
When you can report, you will set the member dwin32exitcode as NO_ERROR.
The last two members dwcheckpoint and dwwaithint are a service to report its current things.
The progress of progress. When member dwcurrentstate is set to service_start_pending
It should be set to 0, and DWWAITHINT should be set into a comparison after multiple attempts.
Appropriate number, such a service can run efficiently. Once the service is fully initialized, it should be reinitialized.
Members of the service_status structure, change dwcurrentstate is Service_Running, then put
DWCHECKPOINT and DWWAITHINT are changed to 0.
The presence of dwcheckpoint members is beneficial to the user, it allows a service to report it in progress
From the step. When you call SetServiceStatus every time, it can be added to a responsible service.
Which step is performed, it helps users decide how long it is reporting to report a service.
If you decide every step to report the initialization process of the service, you should set DWWAITHINT to think that you think
To the next step, the number of milliseconds you need is not required to complete its process.
After all of the initialization of the service, the service calls setServiceStatus specified
Service_running, at that moment service has started running. Usually a service is putting itself in one
The loop is running. The service process in the circulatory is hover, waiting to indicate it next step.
Network requests or notifications such as should be paused, continued or stopped. When a request arrives, the service
Thread activates and processes this request, and then loop back to wait for the next request / notification.
If a service is activated due to a notice, it will handle this notification first unless this service is
It is a notification to stop or close. If you really stop or close, the service thread will exit the cycle.
, Execute the necessary clear operation, then return from this thread. When the servicemain thread returns and aborts
At the time, the thread activated in STARTSERVICECTRLDISPATCHER is activated, and is as explained earlier.
Then, reduce the count of services it run.
(3) Under the in-depth discussion of services
Now we have a function to discuss in detail, that is, the Ctrlhandler letter of the service.
number.
When calling the RegisterServiceCtrlHandler function, SCM gets and saves this callback function
the address of. A SCP tunes a Win32 function telling the SCM to control the service, and now there is 10 predefined control requests:
Control code meaning service_control_stop requests the service to stop. The Hservice handle
Must Have Service_Stop Access. service_control_pause requests the service to pause. The HService
Handle Must Have Service_Pause_Continue Access. service_control_continue requests the paused service to resume. The Paused Service To Resume.
HService Handle Must Have Service_Pause_Continue Access. Service_Control_INTERROGATE Requests The Service To Update Immedietely
ITS Current Status Information To The Service Control Manager. The Service Control Manager. The Service Control Manager..
HService Handle Must Have Service_Interrogate Access. Service_Control_Shutdown Requests The Service To Perform Cleanup
Tasks, Because The System Is Shutting Down. for more information, see
Remarks. Service_control_Paramchange Windows 2000: Requests The Service To
Reread its Startup Parameters. The Hserve Handle Must Have
Service_pause_continue access. Service_control_netbindchange windows 2000: Requests the service to
Update ITS Network Binding. The Hservice Handle Must Have
Service_pause_continue access. Service_control_netbindremove Windows 2000: Notifies a Network Service
That a Component for Binding Has Been Removed. The Service Should
Reread ITS Binding Information and Unbind from the removonent. service_control_netbindenable Windows 2000: Notifies a Network Service
That a disabled binding has been enabled. The Service Should Reread
ITS Binding Information and add the new binding. service_control_netbinddisable Windows 2000: Notifies a network
Service That ONE of Its Bindings Has Been Disabled. The Service Should
Reread its binding information and remove the binding.
The upper table is a winning of Windows 2000 is the newly added control code in 2000. In addition to these generations
In addition to the code, the service can also accept the code defined between 128-255. When the CtrlHandler function receives a service_control_stop,
Service_control_pause, service_control_continue control code,
SetServiceStatus must be called to confirm this code and specify that you think the service is handled.
The time required for changes.
For example: Your service receives a stop request, first put the service_status structure
DWCurrentState members are set to service_stop_pending, so that the SCM determines that you have
Received control code. When a service is suspended or stopped, you must specify you.
Time required for this operation: This is because a service may not change its status immediately, it can
It must be waited for a network request to be completed or the data is refreshed onto a drive. Specify time
Law is like the last chapter, use members dwcheckpoint and dwwaithint to indicate it to complete
Change the time required. If necessary, you can use the value and settings of the dwcheckpoint member.
DWAITHINT member's value to indicate the period of the way you expect the service to reach the next time periodic report
The progress.
When the entire start-up process is completed, you have to call SetServiceStatus again. At this time
The DWCURRENTSTATE member of the service_status structure is set to service_stopped, when reporting
At the same time as code code, be sure to set members dwcheckpoint and dwwaithint to 0 because the service has been
After completing its status change. The method is the same when paused or continues.
When the ctrlhandler function receives a service_control_interrogate control code
The service will make simple set DWCurrentState members into the current state of service, at the same time, put members
DWCHECKPOINT and DWWAITHINT are set to 0, and then call setServiceStatus.
When the operating system is turned off, the ctrlhandler function receives one
Service_control_shutdown control code. The service does not need to respond to this code because the system is
Will be closed. It will execute the minimum action set required for saving data, which is to determine that the machine can turn off timely.
. Only when the system is default, it is only to close all the services, and the msdn is about 20 seconds.
But that may be the setting of Windows NT 4, in my Windows 2000 Server this time
It is 10 seconds, you can manually modify this value, it is recorded
HKEY_LOCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / Control subkey
WaitTokillServentimeout, unit is milliseconds.
When the CtrlHandler function receives any user-defined code, it should perform the desired user
Define actions. Do not adjust or stop unless user-defined actions to be enforced, continue or stop, otherwise
SetServiceStatus function. If the user-defined action is forced to change the status,
SetServiceStatus will be called to set DWCurrentState, dwcheckpoint and dwwaithint
, The specific control code is the same as before.
If your CtrlHandler function takes a long time to perform operation, you must pay attention: fake
If the CtrlHandler function does not return in 30 seconds, the SCM will return an error. This is not our place.
Expected. So if the above situation occurs, the best way is to build a thread and let it continue to perform the operation so that the CtrlHandler function returns quickly. For example, when receiving one
When Service_Control_stop requests, just like the above, the service may be waiting for one
The network request is completed or the data is refreshed on a drive, and the time required for these operations is you
If you can't estimate, then you have to create a new thread wait for the operation to perform the stop command.
CtrlHandler functions still want to report service_stop_pending status before returning, when new lines
After the operation is performed, it will be set to service_stopped by it by it. If the current exercise
Time can be estimated to do this, still use the method of the previously explained.
CtrlHandler function I will talk about this first, and how to install the service. A service program
Add the information of the service to the SCM database with the CreateService function.
SC_Handle CreateService (SC_Handle Hscmanager, // Handle To SCM
Database LPCTSTR LPSERVICENAME, // Name of Service To Start LPCTSTR
LPDisPlayName, // Display name DWord DwdesiredAccess, // type of
Access to Service DWord DWServiceType, // Type of Service DWORD
DWStartType, //hen to start service dword dwerrorcontrol, //
Severity of Service Failure Lpctstr LPBINARYPATHNAME, / / NAME OF
Binary file lpctstr lplandordergroup, // name of load ordering group
LPDWORD LPDWTAGID, // Tag Identifier LPCTSTSTR LPDEPENCIES, // Array
Of dependency names lpctstr lpserviceStartName, // Account Name
LPCTSTSTWORD // Account Password);
Hscmanager is a handle indicating the SCM database that can be simply called
OpenSCManager is obtained.
SC_Handle OpenScManager (LPCTSTSTR LPMACHINENAME, / / COMPUTER NAME
LPCTSTR LPDATABASENAME, / / SCM Database Name DWORD DWDESIREDACCESS /
Access type);
LPMACHINENAME is the name of the target machine, I still remember that I have said in the first chapter.
Is it installed on the machine? This is the implementation method. The other machine name must start with "//". Such as
If you pass NULL or an empty string, you will be a machine.
LPDATABASENAME is the name of the SCM database above the target machine, but this parameter is said in MSDN.
To set it to Services_Active_Database, if null is passed, the default open
Services_Active_Database. So I haven't really figured out the existence of this parameter, always
When you use it, you will pass NULL.
DwdesiredAccess is access to the SCM database, with the specific value of the following table:
Object access Description SC_MANAGER_ALL_ACCESS Includes STANDARD_RIGHTS_REQUIRED, in additionto all of the access types listed in this table. SC_MANAGER_CONNECT Enables connecting to the service control manager. SC_MANAGER_CREATE_SERVICE Enables calling of the CreateService
Function to create a service Object and add it to the database. sc_manager_enumerate_service enables calling of the enumserviceSstatus
Function to List the Services That Are In The Database. SC_MANAGER_LOCK Enables Calling of the LockServiceDatabase Function To
Acquire a lock on the database. SC_Manager_Query_lock_status enables calling of there
QueryServiceLockStatus Function to Retrieve The Lock Status
Information for the database, INFORMATION.
If you want to get access, it doesn't seem to be so complicated. MSDN said that all processes are allowed
Get SC_Manager_Connect, SC_Manager_Enumerate_Service for all SCM databases,
AND SC_MANAGER_QUERY_LOCK_STATUS Permissions, these permissions allow you to connect to SCM databases
, Enumerate whether the service and query target database installed on the target machine have been locked. But if you want to create a service
First, you need to have administrator privileges with the target machine, general delivery
SC_Manager_All_Access is OK. The handle returned by this function can be
The ClosEServiceHandle function is turned off.
LPServiceName is the name of the service, lpdisplayName is the service in the Service Management Tool
The name of the display.
DwdesiredAccess is also accessible, there is a table that is more than the above, each
Check MSDN yourself. We want to install services and still pass SC_Manager_All_Access.
DWServiceType means whether your service is associated with other processes, usually
Service_win32_oen_process, indicating that it is not associated with any process. If you confirm your service
You need to be associated with some processes, set it to service_win32_share_process. When your service
When you are associated with your desktop, you need to set it to service_interactive_process.
DWStartType is a startup method for service. There are three ways to start, namely "automatic
(Service_Auto_Start "" Service_Demand_start "and" Disable
(Service_disabled) "There is still two ways in MSDN, but it is designed for driver.
.
DwerrorControl determines how to do if the service is started when the system is started.
Value Service_Error_Ignore launcher record error occurred, but continues to start. Service_error_normal startup program record error, and pop up a message box, but continue
Start the service_error_severe launcher record error, if it is launched by Last-KNown-GoodConfiguration, the startup will continue. Otherwise it will take Last-KNown-Good
Configuration restarts your computer. Service_error_critical launcher record error occurs, if possible. If it is
Last-KNown-Good Configuration started, the startup failed. Otherwise it will take Last-KNown
-Good Configuration restarts your computer. A good mistake.
LPBINARYPATHNAME is the path to the service program. MSDN is specifically mentioned in the service path
If there is a space, you must cause the path to use quotation marks. For example, "D: // my share // myservice.exe"
Be sure to be specified as "/" d: // my share // myService.exe / "".
The meaning of lplaoadordergroup is that if a set of services should be started in a certain order
This parameter is used to specify a group name for signing this startup sequence group, but I haven't used this yet.
parameter. If your service does not belong to any boot sequence group, just pass null or an empty string
Ok.
LPDWTAGID is a value to be specified after the above parameters applied, dedicated to the driver, and this article
Content is independent. Pass NULL.
LPDependenCIES indicates a string array that specifies the name of a string or a check
The sequence group. When it is associated with a startup order, the meaning of this parameter is only you
At least one of the initial launch sequence groups have all been tried after all members of the entire group
There is at least one member successfully launched, your service can start. If you don't need to establish a dependency, still
It is a string that passes NULL or an empty string. But if you want to specify the start sequence group, you must be a group name.
Plus the SC_GROUP_IDENTIFIER prefix because the group name and service name are shared a namespace.
LPServiceStartName is the service startup account, if you set the type of association of your service is
If service_win32_oen_process, you need to specify in the format of DomainName / UserName
Account name, if this account is in your native, you can specify ./username. If you pass null
If you will log in with a local system account. If you are Win NT 4.0 or earlier, if you finger
The service_win32_share_process must be passed ./system specified service uses local
System account. Finally, if you specify service_interactive_process, you must make the service
Run in the unit system account.
Look at the name, I know, LPPassword is the password of the account. If you specify the system account, pass
NULL. If the account does not have a password, pass a empty string.
The basic principle of the service is like this. In this article, this article seems to be able to tell a paragraph.
But in fact, there are still many things that must be discussed, so I can't figure into a pen, please pay attention to the next chapter.
.