How to make a C language program into Windows service boot

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.