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