Convert service "display name" to "key name" C# -
basically, have large list of "display names" services have in service manager (ie "background intelligent transfer service") , i'm trying figure out how "convert" them service "key names" (ie "bits"). looking up, saw there one solution written in language (delphi) didn't appear use kind of dictionary, implies me there should way in c#. maybe i'm googling wrong, found surprisingly few relevant hits this. has figured out how it?
this print out display name followed service name (referred key name in question):
var services = servicecontroller.getservices(); foreach(var service in services) { console.writeline("{0} = {1}", service.displayname, service.servicename); }
reference system.serviceprocess access servicecontroller.
edit: convert dictionary (for ease of ups) use
var servicenamelookups = servicecontroller.getservices().todictionary(s => s.displayname, s => s.servicename);
then retrieve via:
string servicename; servicenamelookups.trygetvalue("background intelligent transfer service", out servicename)
Comments
Post a Comment