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
naleoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

naleoAuthor Commented:
Found the problem!!!

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....
0
naleoAuthor Commented:
requesting a delete for this question .....
0
Computer101Commented:
Points refunded and placed in PAQ

Computer101
E-E Admin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.