naleo
asked on
service applications has 0 (zero) paramcount despite being started with one or more parameters
I have a small service application. I am trying to enable logging by starting the service with a particular parameter.
I find that no matter how I start the service, the paramcount is always zero. Despite this I can always get a value for paramstr(0).
Can anyone help.
Example of code....
In the ServiceStart event ...
LogMessage('paramstr(0): ' + paramstr(0), EVENTLOG_INFORMATION_TYPE, 0);
LogMessage('paramstr(1): ' + paramstr(1), EVENTLOG_INFORMATION_TYPE, 0);
LogMessage('ParamCount: ' + IntToStr(paramcount), EVENTLOG_INFORMATION_TYPE, 0);
and when the service is started with "loglevel:3" as a start parameter (using the services properties dialog ....) this produces;
paramstr(0) - <path>'\myservice.exe
paramstr(1) - nothing, empty event entry
paramcount - 0
I find that no matter how I start the service, the paramcount is always zero. Despite this I can always get a value for paramstr(0).
Can anyone help.
Example of code....
In the ServiceStart event ...
LogMessage('paramstr(0): ' + paramstr(0), EVENTLOG_INFORMATION_TYPE,
LogMessage('paramstr(1): ' + paramstr(1), EVENTLOG_INFORMATION_TYPE,
LogMessage('ParamCount: ' + IntToStr(paramcount), EVENTLOG_INFORMATION_TYPE,
and when the service is started with "loglevel:3" as a start parameter (using the services properties dialog ....) this produces;
paramstr(0) - <path>'\myservice.exe
paramstr(1) - nothing, empty event entry
paramcount - 0
ASKER
requesting a delete for this question .....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It appears that during the TService.Create event, paramcount is zero, however param[0] will give the name and path of the service.exe.
In the TService.Start event, ParamCount and Param[index] work sort of as expected .... with the exception that param[0] is the name of the service (not the .exe) ... ie: its no good for getting the path of the exe.
Hope this helps someone else....