簡體   English   中英

從C#休眠計算機

[英]Hibernate the computer from C#

我想通過單擊C#Windows Forms Application中的按鈕使計算機休眠。

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

有關更多信息,請參見Application.SetSuspendState()方法。

你可以這樣稱呼它

Application.SetSuspendState(PowerState.Hibernate, true, true)

使用Application.SetSuspendState方法:

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

要么:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM