NtSetThreadExecutionState - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTPOAPI_H

/**
 * Enables an application to inform the system that it is in use,
 * thereby preventing 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.
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetThreadExecutionState(
    _In_ EXECUTION_STATE NewFlags, // ES_* flags
    _Out_ EXECUTION_STATE *PreviousFlags
    );

#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetThreadExecutionState(
    _In_ EXECUTION_STATE NewFlags, // ES_* flags
    _Out_ EXECUTION_STATE *PreviousFlags
    );

#endif

View code on GitHub

Sets the execution state for the current thread and manages the corresponding power requests that prevent the system from dimming the display or entering sleep.

Parameters

Supported flags

Remarks

You can view the power requests created via this and other APIs via powercfg /requests.

Related Win32 API

See also