How does the following code work? It gives the answer how I want. But I want to know how it works? C

Posted by user338096 on Stack Overflow See other posts from Stack Overflow or by user338096
Published on 2010-05-11T09:32:36Z Indexed on 2010/05/11 9:34 UTC
Read the original article Hit count: 108

Filed under:
public static void ShutDownComputer()
    {
        ManagementBaseObject outParameter = null;
        ManagementClass sysOs = new ManagementClass("Win32_OperatingSystem");
        sysOs.Get();
        sysOs.Scope.Options.EnablePrivileges = true;
        ManagementBaseObject inParameter = sysOs.GetMethodParameters("Win32Shutdown");
        inParameter["Flags"] = "8";
        inParameter["Reserved"] = "0";
        foreach (ManagementObject maObj in sysOs.GetInstances())
        {
            outParameter = maObj.InvokeMethod("Win32Shutdown", inParameter, null);
        }
    }

© Stack Overflow or respective owner

Related posts about c#