Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
[FlagsAttribute]
public enum EXECUTION_STATE :uint
{
ES_AWAYMODE_REQUIRED = 0x00000040,
ES_CONTINUOUS = 0x80000000,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_SYSTEM_REQUIRED = 0x00000001
// Legacy flag, should not be used.
// ES_USER_PRESENT = 0x00000004
}
Notes:
Be sure to include in the header: using System.Runtime.InteropServices;
There is no need to store the state you set, Windows remembers it for you. Just set it back to ES_CONTINUOUS when you don't want it anymore.
Also note that this setting is per thread/application not global, so if you go to ES_CONTINUOUS and another app/thread is still setting ES_DISPLAY the display will be kept on.
Setting a flag without also using ES_CONTINUOUS merely resets the idle timer, so it does not prevent sleep for an extended period.
Note that the return value is the EXECUTION_STATE that ''was'' set.
Note ES_AWAYMODE_REQUIRED:
Although Away Mode is supported on any Windows Vista PC, the mode must be explicitly allowed by the current power policy. The Allow Away Mode power setting enables the user to selectively allow Away Mode on one or more power plans or individually for AC and DC (on battery) power states.
(see more about this at http://msdn.microsoft.com/en-us/windows/hardware/gg463208.aspx )
Tips & Tricks:
Description of what the different EXECUTION_STATE does
SetThreadExecutionState is used to stop the machine timing out and entering standby/switching the display device off.
1/19/2014 10:04:08 PM - -62.107.93.107
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).