public uint CallNtPowerInformation(int InformationLevel, IntPtr lpInputBuffer, int nInputBufferSize, long lpOutputBuffer, int nOutputBufferSize) { return(PowerManagerInterop.CallNtPowerInformation(InformationLevel, lpInputBuffer, nInputBufferSize, lpOutputBuffer, nOutputBufferSize)); }
public static Int64 GetLastWakeTime() { IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Int64))); PowerManagerInterop.CallNtPowerInformation(SleepWakeTimeManager.LastWakeTime, IntPtr.Zero, 0, buffer.ToInt64(), Marshal.SizeOf(typeof(Int64))); return(buffer.ToInt64()); }
public static bool ManageHybernateFile(bool isHybernateFileReserved) { IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(bool))); Marshal.WriteInt32(buffer, 0, Convert.ToInt32(isHybernateFileReserved)); bool resultState = false; PowerManagerInterop.CallNtPowerInformation(SystemReserveHiberFile, buffer, 0, resultState, Marshal.SizeOf(typeof(bool))); return(resultState); }
public static byte[] GetSystemPowerInformation() { IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(PowerManagerInterop.SYSTEM_POWER_LEVEL))); uint result = PowerManagerInterop.CallNtPowerInformation(SystemPowerInformation, IntPtr.Zero, 0, buffer, Marshal.SizeOf(typeof(PowerManagerInterop.SYSTEM_POWER_LEVEL))); if (result == STATUS_SUCCESS) { PowerManagerInterop.SYSTEM_POWER_LEVEL powerInfo = (PowerManagerInterop.SYSTEM_POWER_LEVEL)Marshal.PtrToStructure(buffer, typeof(PowerManagerInterop.SYSTEM_POWER_LEVEL)); return(powerInfo.Spare); } else { throw new Win32Exception(Marshal.GetLastWin32Error()); } }
public static uint GetSystemBatteryState() { PowerManagerInterop.SYSTEM_BATTERY_STATE batteryState = new PowerManagerInterop.SYSTEM_BATTERY_STATE(); PowerManagerInterop.CallNtPowerInformation(SystemBatteryState, IntPtr.Zero, 0, batteryState, Marshal.SizeOf(typeof(PowerManagerInterop.SYSTEM_BATTERY_STATE))); return(batteryState.RemainingCapacity); }
public static bool Sleep() { return(PowerManagerInterop.SetSuspendState(false, false, false)); }
public bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent) { return(PowerManagerInterop.SetSuspendState(hibernate, forceCritical, disableWakeEvent)); }