473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Browsing host services

r
Hi,
I would like to create a dialog that shows all services in the
computer, much like services option in the control panel.
How can I traverse all services on the computer?
Thanks in advance

Nov 17 '05 #1
2 1250
Hi,

Find the code below, you could also use ServiceController.GetServices but
you will be able to get all the properties of the services , like imagepath,
or description
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



using System;
using System.IO;
using System.Text;
using System.ServiceProcess;
using System.Web;
using System.Collections;
using Microsoft.Win32;

ArrayList ar = new ArrayList();
//StreamWriter writer = new StreamWriter( "c:\\testwww.txt", false);
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,
"r" <ra****@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,
I would like to create a dialog that shows all services in the
computer, much like services option in the control panel.
How can I traverse all services on the computer?
Thanks in advance

Nov 17 '05 #2

"r" <ra****@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,
I would like to create a dialog that shows all services in the
computer, much like services option in the control panel.
How can I traverse all services on the computer?
Thanks in advance


Use the System.Management namespace classes and WMI for these kind of
management tasks....

using System.Management;

....
// Get all properties of all services
SelectQuery query = new SelectQuery("SELECT * FROM Win32_Service");
using(ManagementObjectSearcher searcher = new
ManagementObjectSearcher(query))
{
foreach(ManagementObject service in searcher.Get())
{
foreach(PropertyData pd in service.Properties)
Console.WriteLine("Property: {0}, Value: [{1}]",pd.Name,
pd.Value);
}
}

Willy.
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: redneck_kiwi | last post by:
Need some opinions on how best to display in excess of 14K records based on users search criteria. Application Concept: ----------------------- User enters various search criteria (as many...
26
by: Dan Nash | last post by:
Hi guys I have a page that is *supposed* to list the directories on the server. Here's the code... folderspec = server.MapPath("./images/") set fso =...
1
by: Dave | last post by:
I know that Remoting requires a host application on the server. Is it possible to use COM+ as the host? If so, where can a good example be found?
4
by: balmerch | last post by:
Is there a way to host the mappoint control in vb.net? I don't want to use the web service because the destination system will not have internet. I tried to host it and got an error about the...
1
by: poc0123 | last post by:
hello had a host running iis and web services, things were ok then renamed host and problems started... like web services not making the connection to a local database running under the IUSR...
2
by: Ludovic DE FREITAS | last post by:
Hello, I am making a prototype system with a Pocket PC that must connect to a Server Application. Unfortunately, the server cannot be a Web Server, but a simple Windows Forms Application. ...
1
by: WolfsonNYC | last post by:
Anyone know how to enable Directory Browsing using the Cassini web server on .Net 2.0 ? Right now it says HTTP Error 403 - Forbidden when I go to a folder on my web site. Thanks, JW
0
by: =?Utf-8?B?UmljaGFyZCBDb2xsZXR0ZQ==?= | last post by:
My goal is to connect a WSE 3.0 client to a WCF asp.net hosted service, utilizing MTOM encoding and if at all possible, streamedRequest transfer mode. I am starting with a basic Hello World...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.