C A method that checks whether Windows has installed a service

  • 2021-01-14 06:28:21
  • OfStack

This article illustrates C#'s method of checking whether Windows has a service installed. Share with you for your reference. The details are as follows:

C# code as follows:


public static void ISWindowsServiceInstalled(string serviceName)
{
  // get list of Windows services
  ServiceController[] services = ServiceController.GetServices();
  foreach (ServiceController service in services)
  {
    if (service.ServiceName == serviceName)
      return true;
  }
  return false;
}

I hope this article is helpful to your C# programming.


Related articles: