GetSystemPowerStatusEx (coredll)
Last changed: -77.79.231.158

.
Summary
Retrieves the power status of the system.

C# Signature:

[DllImport("coredll.dll")]
static extern bool GetSystemPowerStatusEx(out SYSTEM_POWER_STATUS_EX pStatus,
   bool fUpdate);

VB .NET Signature:

Declare Function GetSystemPowerStatusEx Lib "coredll.dll" _
   (<Out()> ByRef pStatus As SYSTEM_POWER_STATUS_EX, _
   ByVal fUpdate As Boolean) As Boolean

User-Defined Types:

SYSTEM_POWER_STATUS_EX

Notes:

If fUpdate is true, the values will be read directly from the low level driver. If false, they may be cached values and may be several seconds old.

Tips & Tricks:

Please add some!

Sample Code:

   public static byte GetBatteryLeftPercentage()
   {
      SYSTEM_POWER_STATUS_EX powerStatus;
      if (GetSystemPowerStatusEx(powerStatus, true))
     return powerStatus.BackupBatteryLifePercent;
      else
     return 100; // assume full power if failed
   }

Alternative Managed API:

TODO

Documentation