c# - W7 : Clean up before go to stand by

标签 c# windows-7

我有一个问题,在进入待机模式之前我需要清理一些东西。 问题是,当客户按下电源按钮(如果配置为进入休眠模式)时,我也需要这样做。

PowerSetRequest(_PowerRequest, PowerRequestType.PowerRequestAwayModeRequired);

这个不行,电脑直接休眠。

我也试过

SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED );

但也失败了。

有人给我提示吗?

最佳答案

以下引自SetThreadExecutionState function表明这不再可能:

The SetThreadExecutionState function cannot be used to prevent the user from putting the computer to sleep. Applications should respect that the user expects a certain behavior when they close the lid on their laptop or press the power button.

关于c# - W7 : Clean up before go to stand by,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30068952/

相关文章:

c# - 使用 .NET 和 Powershell 远程推送 PFX 证书和私钥

c# - 诊断 asp.net 网站/应用程序池的性能

function - 创建带有可选调用变量的函数

c# - 使用 Caliburn.Micro 在 Windows Phone 上进行 Facebook 身份验证回调

c# - 第二个线程在第一个线程释放之前进入锁

c# - 读取内存中的整个文件 VS 读取 block

c++ - boost Asio 错误

c# - 无法获取窗口句柄,不支持 Windowless ActiveX 控件?

c# - 如何获取 Windows 资源管理器中使用的驱动器图标?

c - Eclipse CDT 在底层对 'make' 做了什么