Passing Parameters to a Windows Service?

I have a hand-coded service running without parameters but would now like to pass a parameter to influence its action.

Docs say the main procedure is prototyped thus : Main(LONG dwArgs,LONG lpszArgs)

but where do the parameters come from, I can’t see where to specify them when creating the service?

I stumbled across some text saying “parameters are passed by the calling code” implying that this is outside the OS service manager.

Has anybody accessed lpszArgs?

Hi Julian,

In the registry you will see the instruction for starting your service. Like this:
[HKLM\SYSTEM\CurrentControlSet\Service\MyService]
“ImagePath”:\C:\Projects\MyService\bin\MyService.exe parameter1 parameter2

You can enter the requested values in parameter1 parameter2 …

Regards,

Henk