I want to prevent the monitor from going to sleep (the windows setting, not the monitor setting). I am using c++. What call do I make?
class KeepDisplayOn
{
public:
KeepDisplayOn()
{
mPrevExecState = ::SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS);
::SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &mPrevScreenSaver, 0);
::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, FALSE, NULL, 0);
}
~KeepDisplayOn()
{
::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, mPrevScreenSaver, NULL, 0);
::SetThreadExecutionState(mPrevExecState);
}
private:
UINT mPrevScreenSaver;
EXECUTION_STATE mPrevExecState;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With