The original: How to make a C language program into Windows service boot from
The current program is a C language to implement the socket listening, then how to make this program boot from it?
We compiled the. exe file by vs6.0, and then the EXE file to boot from the startup settings. The setup steps are as follows:
First, register the service name.
(1) Download Instsrv.exe and srvany.exe two files. and copy it to the C:\WINDOWS folder.
(2) Execute the order. C:\windows>instsrvhope C:\WINDOWS\srvany.exe
Here, the service name I want to add is called hope. The following information is prompted:
Make sure this you go to the Control Panel and use
The Services applet to the account Name and
Password that this newly installed service would use
For its Security Context.
Second, find the connection.
(1) In order for the Hope Service to function properly, the application corresponding to the service must be specified in the registry. Run regedit.
Find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services, here is the hope service we just created.
(2) Click Hope, select "New"-"item" and name it parameters.
Select parameters, create a new string value named application in the right-hand window, and set its value data to the application absolute path for the hope service, such as: D:\SDTEL\test\Debug\test.exe.
(3) Next, create two string values: Appdirectory and appparameters. Where appdirectory specifies the directory where the program is located "here is: D:\SDTEL\test\Debug", Appparameters indicates the operation parameters of the program, of course, if not, the value of this can be empty do not write "here, my main function does not have a parameter, so I woke up empty, do not write."
Configure the picture as follows:
(4) Next, open "services", locate the Hope service you just added, open its Properties dialog box, select the "Login" tab,
"Login Identity" select "Local System Account", if you do not want the service to pop up the status window when running, do not tick the "Allow service to desktop interaction" check box, click OK. "Note that in our case we need to see what the console prints, and here's the check box we need to check." 】
The configuration image is as follows:
(5) When you click OK, start the service.
How to make a C language program into Windows service boot