Brief introduction:
The Cwmiutilities class is a simple WMI manipulation tool that encapsulates some of the WMI COM APIs provided by Windows, primarily for reading or setting the properties of a WMI instance, such as the ability to read through WMI, set the system's various information, state, and so on.
Usage:
The Cwmiutilities class resembles the ADODB. The RecordSet, which uses the following code ( the ability to read the CPU information of the system ).
//Construction cwmiutilities
cwmiutilities WMI;
//Connect to WMI Namespace "root\cimv2"
if (!WMI.Connectwmi("Root\\cimv2"))
{
TRACE("Failed to connect to the namespace!" \ n ");
return;
}
//Execute WQL statement
if (!WMI.ExecQuery("SELECT * from Win32_Processor"))
{
TRACE("failed to execute WQL statement!" \ n ");
return;
}
//Traversal
CStringStr;
while(Wmi.Next())
{
//Read properties of WMI Instance
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);
}
}
Output Result:
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
Simple WMI Operation Tool class Cwmiutilities