How do you get the current battery level in .NET CF 3.5?

后端 未结 3 1762
说谎
说谎 2020-12-17 06:49

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?

3条回答
  •  死守一世寂寞
    2020-12-17 07:21

    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.

提交回复
热议问题