h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

List of Windows Service using C#

Introduction A long running executable that's designed to work without user interaction.
It can be configured to start when the system boots and they can be run without any users logged into the system.
Get list of installed windows services ServiceContro­ller.GetServi­ces: get list of all services.
ServiceContro­ller.GetDevices: get list of driver services.
How to use in C#.net? · Create Project.
· Add Datagridview on the Form.
· Add “System.ServiceProcesss” using AddReference.
Add namespace:
using System.ServiceProcess;
Add Method:
void listofservice()
{
// get list of Windows services
System.ServiceProcess.ServiceController[] services = ServiceController.GetServices();
DataTable dt = new DataTable(); //add DataTable
DataColumn dc = dt.Columns.Add("ServiceName");
DataColumn dc1 = dt.Columns.Add("Display Service Name");
dc.Caption = "Service Name"; // set the caption
dc1.Caption = "Dispaly Service Name"; // set the caption
// try to find service name
foreach (ServiceController service in services)
{
dt.Rows.Add(service.ServiceName, service.Status);//add DataRow to DataTable by values
}
dataGridView1.DataSource = dt;
}
private void Form1_Load(object sender, EventArgs e)
{
listofservice();
}