标签:
用法:
CWmiUtilities类形似于ADODB.RecordSet,具体用法参考如下代码(实现读取系统CPU信息的功能)。
//构造CWmiUtilities
CWmiUtilities wmi;
//连接到WMI命名空间“root\CIMV2”
if (!wmi.ConnectWmi("root\\CIMV2"))
{
TRACE("连接到命名空间失败!\n");
return;
}
//执行WQL语句
if (!wmi.ExecQuery("Select * From Win32_Processor"))
{
TRACE("执行WQL语句失败!\n");
return;
}
//遍历
CString str;
while(wmi.Next())
{
//读取WMI实例的属性
if (wmi.GetStringProperty("DeviceID",str))
{
TRACE("%s,",str);
}
if (wmi.GetStringProperty("Name",str))
{
TRACE("%s,",str);
}
if (wmi.GetStringProperty("ProcessorId",str))
{
TRACE("%s\n",str);
}
}
输出结果:
CPU0,Intel(R) Pentium(R) D CPU 2.80GHz,BFEBFBFF00000F64
CPU1,Intel(R) Pentium(R) D CPU 2.80GHz,BFEBFBFF00000F64
http://files.cnblogs.com/dgx/WmiUtilities.rar
标签:
原文地址:http://www.cnblogs.com/dgx/p/5491528.html