public static extern uint CallNtPowerInformation( PowerInformationLevel InformationLevel, IntPtr lpInputBuffer, int nInputBufferSize, ref SystemBatteryState lpOutputBuffer, int nOutputBufferSize );
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); }