我想通过单击C#Windows窗体应用程序中的button来hibernate我的计算机。
private void Button1_Click(object sender, EventArgs e) { //Hibernate the computer }
使用Application.SetSuspendState
方法:
private void button1_Click(object sender, EventArgs e) { Application.SetSuspendState(PowerState.Hibernate, true, true); }
要么:
using System.Diagnostics; Process.Start("shutdown", "/h /f");
有关更多信息,请参阅Application.SetSuspendState()
方法。
你可以这样称呼它
Application.SetSuspendState(PowerState.Hibernate, true, true)