[Solved] C create and run windows service


I think you miss some important requirements for a windows service.According to the MSDN.

You need a service main function and a control handler function as you can’t handle the “start” command if there’s no control handler function registered.

So you can refer to the code to know how to wrote a ServiceMain Function and install it.

If you want to open the service, according to Starting a Service:

To start a service, a service control program opens a handle to an
installed database and then specifies the handle in a call to the
StartService function. After starting the service, the program uses
the members of the SERVICE_STATUS_PROCESS structure returned by the
QueryServiceStatusEx function to track the progress of the service.

I recommend you refer to the complete sample of using the service, which will greatly help you use the service.

solved C create and run windows service