public int state()
{
ConnectionOptions co = new ConnectionOptions();
co.Username = textEdit1.Text;
co.Password = textEdit2.Text;
co.EnablePrivileges = true;
co.Impersonation = ImpersonationLevel.Impersonate;
ManagementScope scope = new ManagementScope(string.Format(@"\{0}rootCIMV2", textEdit3.Text));
scope.Options = co;
scope.Connect();
ObjectQuery query = new ObjectQuery(string.Format("select * from Win32_Service where name = 'r_server'"));
searcher = new ManagementObjectSearcher(scope, query);
queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
if (m.GetPropertyValue("State").ToString() == "Running")
{
retState = 1;
}
else
{
retState = 0;
}
}
return retState;
}
0.00 (0%) 0 votes









