Is there a way for an .NET library to detect whether or not it is being run as a service?
My library can be run either way. But when its run as a service, developer
The answer by 0xA3 to this question actually contains C# code to query the SCM, much like Rob Parker describes in his answer.