c++ - 如何在程序执行期间防止屏幕保护程序和 sleep ?

标签 c++ windows-7 sleep

在 Win7 上运行的 c++ 程序中,有没有办法伪造鼠标移动或类似的东西,只是为了防止屏幕保护程序启动和系统进入休眠状态?我正在寻找最小的方法,我不喜欢使用 .NET。 谢谢, -nuun

最佳答案

不要乱用屏保设置,使用SetThreadExecutionState .这是用于通知窗口您的应用程序处于事件状态的 API:

Enables an application to inform the system that it is in use, thereby preventing the system from entering sleep or turning off the display while the application is running.

,和

Multimedia applications, such as video players and presentation applications, must use ES_DISPLAY_REQUIRED when they display video for long periods of time without user input

关于c++ - 如何在程序执行期间防止屏幕保护程序和 sleep ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3665332/

相关文章:

c++ - 如何区分存储在模板类中的类型

macos - 通过 MAC 上的 VMWare Fusion 在 Windows 上运行 XAMPP,如何配置 apache 以使用我的共享文件夹 (Z :) as the web root?

c# - .NET 应用程序无法在 Windows 7 中打开

python - 如何以毫秒为单位使用 time.sleep()

iPhone 电池续航时间建议

c# - Windows 服务 OnPowerEvent

c++ - 使用继承类作为映射值

c++ - 无序多集的散列/crc 算法

c++ - boost is_invocable_v和is_invocable::value返回不同​​的结果

unicode - 将 Unicode 字符打印到 PowerShell 提示符