Re: Windows services

new topic     » goto parent     » topic index » view thread      » older message » newer message

The general flow of a service program is this: 1) Register the DispatchTable, which contains a callback to the service start routine. 2) In the service start routine: 2a) Register the callback to the service handler routine. 2b) Have a payload loop that does whatever the service needs to do. Usually, this will have a call to sleep() for some seconds since you're usually checking for a condition periodically to take action on.

The winsvctest.exw program included in the zip file you downloaded is as basic as it gets. I recommend you use that file as a template for whatever project you're working on. The text "MyService" on line 96 is irrelevant and can stay as it is. The service name "MyService" in line 53 should be changed to the name you plan to use when you install the service (sc create...). The payload is in lines 65-79. You'll customize this loop for your own needs. If you'd rather not make a call to GetServiceStatus in each loop iteration, then make doneFlag a file-level variable and set it to 1 between lines 34 and 35 in myServiceHandler.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu