Windows 如何阻止屏保运行,并防止系统关闭显示器和进入待机状态

阻止屏幕保护

bool active = false;
    SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, false, &active, SPIF_SENDWININICHANGE);

防止系统关闭显示器或进入待机状态

程序启动时,调用:

SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);

程序退出时,调用:

SetThreadExecutionState(ES_CONTINUOUS); 

详细参数可参考MDSN:SetThreadExecutionState function

你可能感兴趣的:(Windows,程序设计,ES_CONTINUOUS)