#ifndef _NTPOAPI_H
#if (PHNT_MODE != PHNT_MODE_KERNEL)
/**
* The NtSetThreadExecutionState routine informs the system of execution requirements,
*
* in order to prevent the system from entering sleep or turning off the display while the application is running.
* \param NewFlags New execution state flags.
* \param PreviousFlags Pointer to receive the previous execution state flags.
* \return Successful or errant status.
* \sa https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetThreadExecutionState(
_In_ EXECUTION_STATE NewFlags, // ES_* flags
_Out_ EXECUTION_STATE *PreviousFlags
);
View code on GitHub#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetThreadExecutionState(
_In_ EXECUTION_STATE NewFlags, // ES_* flags
_Out_ EXECUTION_STATE *PreviousFlags
);
View code on GitHubSets the execution state for the current thread and manages the corresponding power requests that prevent the system from dimming the display or entering sleep.
NewFlags - a bit mask containing flags thatPreviousFlags - a pointer to a variable that receives the previous execution state.ES_SYSTEM_REQUIRED - prevents the system from going to sleep.ES_DISPLAY_REQUIRED - forces the display to be on.ES_USER_PRESENT - this flag is not supported.ES_AWAYMODE_REQUIRED - enables the away mode that allows the computer appear to be sleeping while being active,ES_CONTINUOUS - the state should remain in effect until the next call that uses this flag.You can view the power requests created via this and other APIs via powercfg /requests.