using System.Management;
...
public static void PowerOff()
{
ManagementClass mc_os = new ManagementClass("Win32_OperatingSystem");
mc_os.Scope.Options.EnablePrivileges = true;
foreach (ManagementObject mo in mc_os.GetInstances())
{
mo.InvokeMethod("Shutdown", null, null);
}
mc_os.Dispose();
}
...
PS. 必須加入參考 : 專案->加入參考->Systme.Management
資料來源 :
http://www.dotblogs.com.tw/nobel12/archive/2009/10/05/10912.aspx
沒有留言:
張貼留言