C# - 如何获取所有电池统计数据? [英] C# - how to get all battery statistics?

查看:120
本文介绍了C# - 如何获取所有电池统计数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的C#后端应用程序,我将收集与连接到Windows设备的电池相关的所有数据,有关电池的数据将类似于电池电量,电池技术, 电池电源,电池电压,电池健康状况等。



我尝试过:



经过大量的互联网搜索,我找不到任何有用的东西。与我的查询更接近的唯一选择是UWP应用程序,但我现在不在使用UWP应用程序。我正在使用Simple Console C#Application,任何人都可以帮我在windows中找到一些好的和有用的电池管理API吗?

I'm working on a simple C# Back-end App where I've to collect all the data related to battery which is connected to windows Device, Data about battery would be like "Battery Level" , "Battery Technology" , "Battery Power Source" , "Battery Voltage" , "Battery Health" etc.

What I have tried:

After a lot of internet search I couldn't find anything useful. The only option that is a little bit closer to my query is UWP Apps, But I'm not working on UWP app now. I'm working with Simple Console C# Application , Can any body help me to find out some good and useful API for battery management in windows?

推荐答案

见这里:< a href =https://msdn.microsoft.com/en-us/library/system.windows.forms.powerstatus(v=vs.110).aspx> PowerStatus Class(System.Windows.Forms) [ ^ ] - 它为您提供了您可以获得的信息。

但是您想要的一些项目并不那么简单:例如,健康状况并不是真正的状态项目,这是你只能评估一系列充电/使用周期的东西,它真的是电池故障的指标,而不是健康状况 - 而且我不认为Windows会记录这些信息!



您可以通过直接查询WIN32获得更多信息:来自win32 ap的电池信息i·GitHub [ ^ ]但即便如此,我不要以为你会很容易得到你想要的一切。
See here: PowerStatus Class (System.Windows.Forms)[^] - that gives you the info you can get.
But some of the items you want aren't that simple: Health for example isn't really a "status" item, it's something that you can only assess over a series of charge / use cycles, and it's really an indicator of battery failure rather than health - and I don;t think windows records that info!

You may be able to get more info by querying WIN32 directly: Battery info from win32 api · GitHub[^] but even then, I don;t think you will get everything you want that easily.


这篇关于C# - 如何获取所有电池统计数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆