Friday, August 23, 2013

C++ prevent windows from sleeping

When connecting through HDMI to a monitor, the windows 8 seems to have a problem in power management. Even if I set sleep time to never, it still sleeps.

So I wrote a program to prevent the sleep. The key API is:

SetThreadExecutionState(ES_CONTINUOUS|ES_DISPLAY_REQUIRED)
This keeps system and monitor on.

SetThreadExecutionState(ES_CONTINUOUS|ES_SYSTEM_REQUIRED)
This keeps system on.

No comments:

Post a Comment