CIM_Battery WMI Class 没有实例

CIM_Battery WMI Class has no instances

我正在尝试创建一个 C# 应用程序来记录一段时间内的电池电量百分比,为此我一直在尝试使用 .NET WMI API。我查看了 MSDN,发现有一个名为 CIM_Battery, and confirmed its existence with wbemtest.exe.

的 WMI class

此方法的唯一问题显然是 CIM_Battery class 没有我可以读取的实例。

我知道电池监控软件可以成功读取我笔记本电脑上的电池百分比,所以我知道它可以在我的笔记本电脑上使用。我是否尝试使用错误的工具来完成工作?

是的,你做错了。来自 MSDN Page for the CIM_Battery class:

Important: The DMTF (Distributed Management Task Force) CIM (Common Information Model) classes are the parent classes upon which WMI classes are built.

CIM_[WHATEVER] classes 只是其他 class 可以实现的模板或模型。对于电池,要查看的正确 WMI class 是 win32_battery class,它实现了 CIM_Battery 模型。