列出机器上的 windows services

列出机器上的 windows services C# code snippet


// Get a list of installed windows services

ServiceController[] services = ServiceController.GetServices();
public static bool IsServiceInstalled(string serviceName)
{
  ServiceController[] services = ServiceController.GetServices();

  foreach (ServiceController service in services)
  {
    if (service.ServiceName == serviceName)
      return true;
  }
  return false;
}