GetSystemPowerCapabilities() { PowerManagementNativeMethods.SystemPowerCapabilities powerCap; uint retval = PowerManagementNativeMethods.CallNtPowerInformation( PowerManagementNativeMethods.PowerInformationLevel.SystemPowerCapabilities, IntPtr.Zero, 0, out powerCap, (UInt32)Marshal.SizeOf(typeof(PowerManagementNativeMethods.SystemPowerCapabilities)) ); if (retval == CoreNativeMethods.StatusAccessDenied) { throw new UnauthorizedAccessException(LocalizedMessages.PowerInsufficientAccessCapabilities); } return(powerCap); }
internal static PowerManagementNativeMethods.SystemBatteryState GetSystemBatteryState() { PowerManagementNativeMethods.SystemBatteryState batteryState; uint retval = PowerManagementNativeMethods.CallNtPowerInformation( PowerManagementNativeMethods.PowerInformationLevel.SystemBatteryState, IntPtr.Zero, 0, out batteryState, (UInt32)Marshal.SizeOf(typeof(PowerManagementNativeMethods.SystemBatteryState)) ); if (retval == CoreNativeMethods.StatusAccessDenied) { throw new UnauthorizedAccessException(LocalizedMessages.PowerInsufficientAccessBatteryState); } return(batteryState); }