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.
EXECUTION_STATE WINAPI SetThreadExecutionState(
_In_ EXECUTION_STATE esFlags
);
防止系统进入睡眠、防止关闭显示器、防止屏幕保护
SetThreadExecutionState(ES_DISPLAY_REQUIRED|ES_CONTINUOUS | ES_SYSTEM_REQUIRED );
允许系统进入睡眠、防止关闭显示器、防止屏幕保护
SetThreadExecutionState(ES_CONTINUOUS);
注:成对使用。