我想将我的系统置于睡眠或休眠状态,这是两个不同的选项。
我该如何使用API来实现这一目标?我不想使用Process,因为它不能让我选择所需的操作方法。
// Hibernate
Application.SetSuspendState(PowerState.Hibernate, true, true);
// Standby
Application.SetSuspendState(PowerState.Suspend, true, true);
或者,如果你喜欢使用系统调用:
[DllImport("Powrprof.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent);
// Hibernate
SetSuspendState(true, true, true);
// Standby
SetSuspendState(false, true, true);