无需 WMI 即可获取电池信息
有没有办法在没有 WMI 的情况下获取电池 DesignCapacity 和 FullChargeCpacity ? WMI 不支持此值,因此我需要找到其他方法来获取它们。
或者也许有人有更好(更简单)的想法来获取 C# 中电池的磨损程度?
顺便提一句 我尝试以这种方式使用它,但只是返回 null
ManagementObjectSearcher query =
new ManagementObjectSearcher("SELECT DesignCapacity FROM Win32_Battery");
foreach (ManagementObject queryObj in query.Get())
{
string dc = Convert.ToString(queryObj.GetPropertyValue("DesignCapacity"));
label1.Text = dc + " mAh";
}
谢谢
Is there some way to obtain the battery DesignCapacity and FullChargeCpacity without WMI ?
This values are not supported in WMI so I need to find other way to get them.
Or maybe somebody have better (easier) idea to get the wear level of battery in C#?
BTW
I try to use it this way but just returned null
ManagementObjectSearcher query =
new ManagementObjectSearcher("SELECT DesignCapacity FROM Win32_Battery");
foreach (ManagementObject queryObj in query.Get())
{
string dc = Convert.ToString(queryObj.GetPropertyValue("DesignCapacity"));
label1.Text = dc + " mAh";
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取这些特定值,您需要针对不同的类而不是 win32_battery 进行单独的查询。
DesignCapacity
可以从 BatteryStaticData 查询FullChargeCacity
可以从 BatteryFullChargedCapacity 查询您还需要在代码中使用不同的范围来进行查询。这些类位于
root/WMI
中,而不是root/cimv2
To get those particular values you need to do separate queries against different classes instead of win32_battery.
DesignCapacity
can be queried from BatteryStaticDataFullChargeCacity
can be queried from BatteryFullChargedCapacityYou'll need to use a different scope in the code also for the query. These classes are found in
root/WMI
instead ofroot/cimv2