C#让pc睡眠或hibernate
我想将我的系统置于睡眠或hibernate状态,两种不同的选择。
我如何使用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);