Programming/C#2011. 12. 25. 02:06

The source codes seem like working only for Window OS 32bit, but 64 bit works perfectly The only problem is "privilege" That's the problem. we must run this application as an administration
       


                     ManagementBaseObject mboShutdown = null;
                    ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem");
                    mcWin32.Get();
                    mcWin32.Scope.Options.EnablePrivileges = true;      // get security privileges
                    ManagementBaseObject mboShutdownParams = mcWin32.GetMethodParameters("Win32Shutdown");
                    mboShutdownParams["Flags"] = "1";
                    mboShutdownParams["Reserved"] = "0";
                    foreach (ManagementObject manObj in mcWin32.GetInstances())
                    {
                        mboShutdown = manObj.InvokeMethod("Win32Shutdown", mboShutdownParams, null);
                    }
                    break;
                    



'Programming > C#' 카테고리의 다른 글

Palindromic number source  (0) 2011.10.19
Posted by 박세범