在 Windows 7 上,我看到使用参数 ES_CONTINUOUS | 调用
阻止用户手动让系统进入休眠状态。SetThreadExecutionState
ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED
打开“开始”菜单并选择“ sleep ”后,显示屏关闭,但我的应用程序继续处理。风扇继续全速运行这一事实证明了这一点,并且在唤醒计算机时,我可以看到 sleep 发生时正在执行的操作已经取得进展。
如何让用户在 SetThreadExecutionState
生效时手动让他们的计算机进入休眠状态?
最佳答案
包含 ES_AWAYMODE_REQUIRED 选项会导致此问题。引用自 MSDN 文章:
The ES_AWAYMODE_REQUIRED value should be used only when absolutely necessary by media applications that require the system to perform background tasks such as recording television content or streaming media to other devices while the system appears to be sleeping. Applications that do not require critical background processing or that run on portable computers should not enable away mode because it prevents the system from conserving power by entering true sleep.
关于windows - SetThreadExecutionState 防止手动休眠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21487960/