Hi,
I'm not very clear of what you want in the first place, you can use the
registry to get extra info not supplied by the ServiceController class, use
the code below for that. Take a look in the registry and see what other nifo
you need.
string[] st = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
"System\\CurrentControlSet\\Services").GetSubKeyNa mes();
StringBuilder sb = new StringBuilder();
foreach( string key in st )
{
object imagePath;
object DisplayName;
if ( (imagePath =Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
"System\\CurrentControlSet\\Services\\" + key).GetValue( "ImagePath"))
== null )
continue;
if ( (DisplayName =Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
"System\\CurrentControlSet\\Services\\" + key).GetValue( "DisplayName"))
== null )
DisplayName = "Unknow";
sb.Append( "Service name=");
sb.Append( key );
sb.Append( " | ");
sb.Append( "DisplayName=");
sb.Append( DisplayName.ToString() );
sb.Append( " | ");
sb.Append( "Service image=");
sb.Append( imagePath.ToString() );
sb.Append( Environment.NewLine );
}
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
<ti******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Scenario:
I have a service which has been installed in the service component
manager.
I am writing a second program (completely unrelated to the service)
which will run stand alone. I can find all of the services on the
machine with the following line of code:
System.ServiceProcess.ServiceController[] foo =
System.ServiceProcess.ServiceController.GetService s();
My question / problem is:
Is there a way for me to use the information returned by the method
call for an instance of a service (a particular service which I know
the name) to map that back to the pathname for the installed service?
If not, does anyone have any suggestions on a different approach to the
problem???
I am using C# (and accordingly .NET)
Thanks -
Tim Burda