public class SYSTEM_POWER_STATUS_EX2 { public byte ACLineStatus; public byte BatteryFlag; public byte BatteryLifePercent; public byte Reserved1; public uint BatteryLifeTime; public uint BatteryFullLifeTime; public byte Reserved2; public byte BackupBatteryFlag; public byte BackupBatteryLifePercent; public byte Reserved3; public uint BackupBatteryLifeTime; public uint BackupBatteryFullLifeTime; public uint BatteryVoltage; public uint BatteryCurrent; public uint BatteryAverageCurrent; public uint BatteryAverageInterval; public uint BatterymAHourConsumed; public uint BatteryTemperature; public uint BackupBatteryVoltage; public byte BatteryChemistry; }
private void BatteryUpdate() { SYSTEM_POWER_STATUS_EX2 status2 = new SYSTEM_POWER_STATUS_EX2(); BatteryStatusLbl.Text = "Power status check failed."; if (GetSystemPowerStatusEx2(status2, (uint)Marshal.SizeOf(status2), false) == (uint)Marshal.SizeOf(status2)) { BatteryStatusLbl.Text = String.Format("{0}%", status2.BackupBatteryLifePercent); } }
The off the shelf BitsyX has no battery or backup battery, and therefore it has only a stub battery driver that returns no useful battery information. If you need it to return information, a battery driver that matches your battery controller is required.