Simple WMI Operation Tool class Cwmiutilities

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.