المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : service startupType



C# Programming
08-05-2009, 10:52 AM
Hi,
The code below looks for a particular service i.e "Index service" and then checks for the status i.e. stopped, start...
How do I modify this code so that I can check for the startupType of the service i.e. disabled, automatic, manual?
Thanks

ServiceController[] installedServices;

installedServices = ServiceController.GetServices(strServer);

foreach (ServiceController tmpService in installedServices)
{
//proceed only if the service is installed...
if (myService.DisplayName.ToLower().Trim() == "Installed Service")
{
//get the status of the service...
strServiceStatus = myService.Status.ToString();

ServiceInstaller serviceInstaller = new ServiceInstaller();
serviceInstaller.ServiceName = strService.ToLower().Trim();
strStartupType = serviceInstaller.StartType.ToString();

}
}