且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在程序执行期间防止屏幕保护程序和睡眠?

更新时间:2023-11-14 12:44:40

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

Don't mess with the screensaver settings, use SetThreadExecutionState. This is the API for informing windows on the fact that your application is active:

使应用程序能够通知它正在使用的系统,从而阻止系统进入睡眠或关闭显示器,同时应用程序正在运行.

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.

,和

多媒体应用,例如视频播放器和演示应用程序,必须使用 ES_DISPLAY_REQUIRED 当他们长时间显示视频无需用户输入

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