Search code examples
c#windows-7battery

How to get battery status in windows 7 via some api?


i want to know is there any way to know by c# code that laptop's battery is fully charged or is there any event raised when the battery is full.


Solution

  • I'm guessing you could use the WMI class Win32_Battery.

    There are multiple fields that could be useful - DesignCapacity, BatteryStatus, FullChargeCapacity or ExpectedLife

    So my guess is that you can use WMI to read these two values, and then calculate FullChargeCapacity/BatteryStatus/DesignCapacity/ExpectedLife to find the battery health percentage number.