2016-06-11 106 views
1

我想通過單擊C#Windows窗體應用程序中的按鈕來休眠我的計算機。從C#休眠計算機#

private void Button1_Click(object sender, EventArgs e) 
{ 
    //Hibernate the computer 
} 

回答

3

使用Application.SetSuspendState方法:

private void button1_Click(object sender, EventArgs e) 
{ 
    Application.SetSuspendState(PowerState.Hibernate, true, true); 
} 

或者:

using System.Diagnostics; 
Process.Start("shutdown", "/h /f");