public SystemBatteryState GetSystemBatteryState() { var sbs = new SystemBatteryState(); uint retval = PowerManagementInterop.CallNtPowerInformation( PowerInformationLevel.SystemBatteryState, IntPtr.Zero, 0, ref sbs, Marshal.SizeOf(sbs)); if (retval != statusSuccess) { throw new Exception("GetSystemBatteryState not success"); } return(sbs); }
public SystemPowerInformation ShowSystemPowerInformation() { SystemPowerInformation spi; uint retval = PowerManagementInterop.CallNtPowerInformation( PowerInformationLevel.SystemPowerInformation, IntPtr.Zero, 0, out spi, Marshal.SizeOf(typeof(SystemPowerInformation)) ); if (retval != statusSuccess) { throw new Exception("SystemPowerInformation not success"); } return(spi); }