Native模式下的程序的函数调用:
ZwSetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED |ES_CONTINUOUS ,&dwRetState);
上层程序:
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED );
Syntax
EXECUTION_STATE WINAPI SetThreadExecutionState( __in EXECUTION_STATE esFlags );
Parameters
-
esFlags [in]
-
The thread's execution requirements. This parameter can be one or more of the following values.
Value Meaning ES_AWAYMODE_REQUIRED
0x00000040Enables away mode. This value must be specified with ES_CONTINUOUS.
Away mode should be used only by media-recording and media-distribution applications that must perform critical background processing on desktop computers while the computer appears to be sleeping. See Remarks.
Windows Server 2003 and Windows XP/2000: ES_AWAYMODE_REQUIRED is not supported.
ES_CONTINUOUS
0x80000000Informs the system that the state being set should remain in effect until the next call that uses ES_CONTINUOUS and one of the other state flags is cleared.
ES_DISPLAY_REQUIRED
0x00000002Forces the display to be on by resetting the display idle timer.
ES_SYSTEM_REQUIRED
0x00000001Forces the system to be in the working state by resetting the system idle timer.
ES_USER_PRESENT
0x00000004This value is not supported. If ES_USER_PRESENT is combined with other esFlags values, the call will fail and none of the specified states will be set.
Windows Server 2003 and Windows XP/2000: Informs the system that a user is present and resets the display and system idle timers. ES_USER_PRESENT must be called with ES_CONTINUOUS.
参见:http://msdn.microsoft.com/zh-cn/library/aa373208(en-us).aspx