Check for a Windows service in C#.

This code will check through a list of installed Windows Services for a specific service name in C# (returns boolean). The function allows you to pass a service name as a string and the function will check the Windows Service list for that name. It will also look for partial service names in case you don’t know the exact name of the service.
public bool IsBonjourInstalled(string sname)
{
ServiceController[] services_array = ServiceController.GetServices();
foreach (ServiceController service in services_array)
{
if (service.ServiceName.Contains(sname))
return true;
}
return false;
}



No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL
Leave a comment