Listing Windows Services registered with OS

The snippet lists all the windows services registered with your local system .


Namespaces to be used:
using System.ServiceProcess;

step 1:design windows form with checkboxlist control

step 2:In page load event




private void Form1_Load(object sender, EventArgs e)
{
int index = 0;
foreach (ServiceController sc in ServiceController.GetServices())
{
checkedListBox1.Items.Add(sc.DisplayName);
if (sc.Status == ServiceControllerStatus.Running)
checkedListBox1.SetItemChecked(index, true);
index++;

}
}


Explanation:
Using service controller object we r getting services. The display name and status of windows service is retrieved using service controller object.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: