Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Get All Window services installed on your machine using System.ServiceProcess in C# .NET 2.0.

Author: Zunnair
Download Source Code : 722_GetAllWndServices.zip

In this simple article you will learn that how you can get All Window service installed on your machine using System.ServiceProcess Namespace.

Simply just create New Project of windows application in C#.

 

Import ServiceProcess APIs

 

using System. ServiceProcess;

 

Drag three labels, one button and one List box on the form.

 

Now write following code on form Load event

 

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DevAsp ALL Windows Services APP";

        }

 

Now write code on buttons events

 

private void button1_Click(object sender, EventArgs e)

        {

 

            ServiceController[] srvs;

            int count = 0;

            try

            {

                srvs = ServiceController.GetServices();

                listBox1.Items.Clear();

                foreach (ServiceController Srvs in srvs)

                {

                    listBox1.Items.Add(Srvs.DisplayName);

                    listBox1.Sorted = true;

                    count += 1;

                }

                label3.Text = count.ToString();

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

 

        }

 

On button1_Click function u will get All Window services installed on your machine.

 

ServiceController.GetServices() function returns all services installed..

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Kill all instances of a process running on your machine using System.Diagnostics Namespace in C# .NET 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net