예제 #1
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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent)
 {
     return(PowerManagementInterop.SetSuspendState(hibernate, forceCritical, disableWakeEvent));
 }