.net – How to get the current battery level in .NET CF 3.5

.netcompact-frameworkdevicepower-managementwindows-mobile

How – or what's the best way – to retrieve the device's current battery level in .NET CF 3.5 on Windows Mobile 5 and 6?

Best Solution

I think you want to use the Microsoft.WindowsMobile.Status namepsace (specifically the SystemState class.

using Microsoft.WindowsMobile.Status;

...

BatteryLevel batteryLevel = SystemState.PowerBatteryStrength;
BatteryState batteryState = SystemState.PowerBatteryState;

See this post for the full code sample.