Function SetThreadExecutionState
Allows a program to inform the system that it is being used, thereby preventing the system from entering sleep mode or turning off the display while the application is running.
Read more about the API here: SetThreadExecutionState
Example:
// The following sets the appropriate flags to prevent system to go into sleep mode. SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED); // This clears the flags and allows the system to sleep normally. SetThreadExecutionState(ES_CONTINUOUS);
source share