Reputation: 2004
Windows Services can have parameters in the registry like in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BITS\Parameters
I want to access the parameters of my own service written in C#. Is there an official way (e.g. via the ServiceBase
class) to do that or do I have to hard-code the registry path, which I want to avoid?
Upvotes: 2
Views: 3967
Reputation: 5623
Are you looking for the paramenters the server WAS started with, or what the registry is saying it should be started with?
If your looking for the parameters that was used to start your app you can use Environment.CommandLine or make surge your main function is declaired like
[STAThread]
static void Main(string[] args)
{
// Do something with args array, but il make sure its not null first.
}
If your are looking for what args it should be started with i see no problem reading that registry setting.
Upvotes: 1