private static void SetState(EXECUTION_STATE state) { Logger.Info("Setting System State to [{0}]", EXECUTION_STATE.ES_CONTINUOUS); try { SetThreadExecutionState(state); } catch (Exception e) { Logger.Error("An error has occurred while setting system state. {0}", e.ToString()); } }
private void PreventSleep() { var lastState = SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED);//Away mode for Windows >= Vista if (lastState == EXECUTION_STATE.ES_INVALID) { lastState = SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED); //Windows < Vista, forget away mode } if (m_initialExcutionState == EXECUTION_STATE.ES_INVALID) { m_initialExcutionState = lastState; } }
private static extern UInt32 CallNtPowerInformation(POWER_INFORMATION_LEVEL InformationLevel, IntPtr lpInputBuffer, UInt32 nInputBufferSize, out EXECUTION_STATE lpOutputBuffer, Int32 nOutputBufferSize);
protected static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE state);
static extern uint SetThreadExecutionState(EXECUTION_STATE esFlags);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
private extern static EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE state);
private static extern EXECUTION_STATE SetThreadExecutionStateNative(EXECUTION_STATE esFlags);
internal static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE state);
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE flags);
public void Execute(object o = null) { Initialized = true; LastExecutionState = WinAPI.SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED); Program.Reader.ReadAsync("Hibernation denied."); }
public static EXECUTION_STATE SetThreadExecutionState (EXECUTION_STATE esFlags) { Console.WriteLine ("Kernel32:SetThreadExecutionState called"); return EXECUTION_STATE.ES_CONTINUOUS; }
public NonSuspendableAction() { // Forces the system to be in the working state until next call that uses ES_CONTINUOUS: previousState = Kernel32.SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED); }
public EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags) { return(SetThreadExecutionStateNative(esFlags)); }
public static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
public static void ResetStandbyTimer() { EXECUTION_STATE es = SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED); }
private static extern EXECUTION_STATE SetThreadExecutionState( EXECUTION_STATE flags);