Reputation: 13257
I want to have Single Executable part of multiple services. i.e. name of the service will be different but the executable will be different.
How Do I identify the which service is called in ServiceMain
Upvotes: 1
Views: 102
Reputation: 23619
You can't. You should give every service its own ServiceMain function.
An example is given on http://msdn.microsoft.com/en-us/library/windows/desktop/bb540475%28v=vs.85%29.aspx.
When this application is run with the "INSTALL" argument, it registers itself as a service using the CreateService function. If your executable offers multiple services, you need to call CreateService multiple times.
When the application is run without the "INSTALL" argument, it fills a DispatchTable and passes it to StartServiceCtrlDispatcher. If your executable supports multiple services, your DispatchTable will contain multiple entries. Give every entry a different ServiceMain function and Windows will call the correct function.
Upvotes: 3