C#判断当前系统服务存在否
private bool ServiceIsExisted(string serviceName)
{
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController s in services)
{
if (s.ServiceName == serviceName)
{
return true;
}
}
return false;
}
其中ServiceIsExisted是BOOL型,IF判断把服务名填充进方法就可以了