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 ServiceControll er 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.Local Machine.OpenSub Key(
"System\\Curren tControlSet\\Se rvices").GetSub KeyNames();
StringBuilder sb = new StringBuilder() ;
foreach( string key in st )
{
object imagePath;
object DisplayName;
if ( (imagePath =Microsoft.Win3 2.Registry.Loca lMachine.OpenSu bKey(
"System\\Curren tControlSet\\Se rvices\\" + key).GetValue( "ImagePath" ))
== null )
continue;
if ( (DisplayName =Microsoft.Win3 2.Registry.Loca lMachine.OpenSu bKey(
"System\\Curren tControlSet\\Se rvices\\" + key).GetValue( "DisplayNam e"))
== null )
DisplayName = "Unknow";
sb.Append( "Service name=");
sb.Append( key );
sb.Append( " | ");
sb.Append( "DisplayName=") ;
sb.Append( DisplayName.ToS tring() );
sb.Append( " | ");
sb.Append( "Service image=");
sb.Append( imagePath.ToStr ing() );
sb.Append( Environment.New Line );
}
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
<ti******@hotma il.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.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.ServiceP rocess.ServiceC ontroller[] foo =
System.ServiceP rocess.ServiceC ontroller.GetSe rvices();
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