Справочник по C#

    Исходники по языку программирования CSharp

    WMI State Service (Проверка состояния службы с помощью WMI): Справочник по C#

    /
    /
    /
    30 Views


    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;
    }
    

    WMI State Service (Проверка состояния службы с помощью WMI): Справочник по C#

    0.00 (0%) 0 votes

    moyadcode13
    • Facebook
    • Twitter
    • Google+
    • Linkedin
    • Pinterest
    moyadcode10
    moyadcode11
    moyadcode9