2016-06-11 76 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");