Accessing Windows service settings in registry from C #

Windows services can have parameters in the registry, for example 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 (via a class, for example ServiceBase

) to do this, or do I need to hard-code the registry path, which I want to avoid?

+2


source to share


1 answer


Are you looking for the parasites that the server started with or what the registry says it should be running?

If you are looking for the parameters that were used to launch your application, you can use Environment.CommandLine or do a splash that declares the main function as



[STAThread]
        static void Main(string[] args)
        {
            // Do something with args array, but il make sure its not null first.
        }

      

If you're looking for what arguments to run, I see no problem reading this registry entry.

+1


source







All Articles