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

て烟熏妆下的殇ゞ 提交于 2020-01-10 02:14:06

问题


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?


回答1:


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.




回答2:


You probably want the State Notification Broker class that Noldorin is recommending. I don't think it gives you very fine grain information. You get information like Low or Very Low. If you need specific percentages consider using GetSystemPowerStatusEx.

HOWTO: Get the Device Power Status GetSystemPowerStatusEx




回答3:


To add to CJ's response you can find a code example of how to get detailed battery information from http://www.codeproject.com/kb/mobile/Wimopower1.aspx . This information includes the batter's power level, temperature, whether it is charging or draining, and the amount of current being drawn.

Example Output http://j2i.net/resized-image.ashx/__size/800x0/__key/CommunityServer.Blogs.Components.WeblogFiles/home/powerMeter.png



来源:https://stackoverflow.com/questions/681717/how-do-you-get-the-current-battery-level-in-net-cf-3-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!