public SYSTEM_POWER_INFORMATION SystemPowerInformation()
        {
            SYSTEM_POWER_INFORMATION powerInfo;
            var result = PowerManagerApi.PowerInformation(InformationLevel.PowerInformation, IntPtr.Zero, 0, out powerInfo, Marshal.SizeOf(typeof(SYSTEM_POWER_INFORMATION)));

            return(powerInfo);
        }
        public SYSTEM_BATTERY_STATE BatteryState()
        {
            SYSTEM_BATTERY_STATE batteryState;
            var result = PowerManagerApi.BatteryState(InformationLevel.BatteryState, IntPtr.Zero, 0, out batteryState, Marshal.SizeOf(typeof(SYSTEM_BATTERY_STATE)));

            return(batteryState);
        }
        public long LastWakeTime()
        {
            long wakeTime;

            PowerManagerApi.LastSleepOrWakeTime(InformationLevel.LastWakeTime, IntPtr.Zero, 0, out wakeTime, Marshal.SizeOf(typeof(long)));
            return(wakeTime);
        }
 public bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent)
 {
     return(PowerManagerApi.SetSuspendState(hibernate, forceCritical, disableWakeEvent));
 }
 public void RemoveHibenationFile()
 {
     PowerManagerApi.ToggleHibernationFile(InformationLevel.SystemHiberFile, false, Marshal.SizeOf(typeof(bool)), IntPtr.Zero, 0);
 }