Geting Window Service Path with out Interop

  • Thread starter Thread starter gordingin
  • Start date Start date
G

gordingin

I need to get the path of a service in C#. Using C++, I can use
QueryServiceConfig() but I wish not to use Interop if I dont have to,
is there a way in C#?

thanks
Ralph
 
Ralph,

This code should return the path & filename of the service executable, you
can use the Path class to parse out the lead-in path:

Process.GetCurrentProcess().MainModule.FileName

--Richard
 
You might also be able to use the entry point for the CLR, through the
static GetEntryAssembly method on the Assembly class (to get the entry
point), and then get the location of the assembly.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top