Writing a service Q: how to get the parameter from...

  • Thread starter Thread starter Roger Twomey
  • Start date Start date
R

Roger Twomey

When I start my service I want to pick up a parameter from Start Parameters
box (in the service control screen). I cannot find the proper method to get
this string. It has to be easy but I cannot find the command(s).

Thanks.
 
When I start my service I want to pick up a parameter from Start Parameters
box (in the service control screen). I cannot find the proper method to get
this string. It has to be easy but I cannot find the command(s).

Thanks.

The OnStart method has an args() parameter. Have you looked at that?
 
I have, I can 'sort of' understand this.

It seems the args come through as an array however when the array is created
it appears to parse on more than one character.

So far I have found it splits on both the space and the semi-colon ;

If it splits on more elements (comma, colon, others??) it seems to make
using the string a bit more complicated. Currently I loop through the array
and concatonate string so that I can split it the way I want.

That seems a bit odd to me.

Is that the way it is supposed to work?

<Thank you by the way, I did not notice the args() in the onstart until you
mentioned it.>
 
So far I have found it splits on both the space and the semi-colon ;

I did not know that it split on the semi colon. I assumed that it split on
a space character. If you have parameters that may include spaces (such as
a filename), you can enclose the paramter in quotation marks and it will be
split properly into the args array.
 
Back
Top