Win32 class and its management object
In the previous section, we have come into contact with the WMI class name in the access management information, such as:
Diskman = new managementClass ("Win32_LogicalDisk")
"Win32_LogicalDisk" is a Win32_LogicalDisk class in the WMI class. In this section, we will learn more about WMI classes. WMI provides a series of WMI class for program users, through these WMI classes, we can do Similar to the operation of the query about WMI, since the WMI class involves all aspects of the system, it is divided into 7 subclasses, respectively:
N WMI SYSTEM CLASSES
N WMI SYSTEM PROPERTIES
N win32 classes
N CIM Classes
N Standard Consumer Classes
N MSFT Classes
N msmca classes
N WMI C Classes
Due to the reason, only the classes in Win32_Classes are explained in this section, and the rest can go to find the contents in the MSDN themselves.
The class in the Win32_Classes subclass is located in the root / cimv2 namespace, which contains most classes related to the system operation, such as the Win32_logicalDisk class described earlier, and the Win32_Process class will be introduced later. In the Win32_Classes subclass, Divided into 5 big, namely:
N Computer System Hardware (Computer System Hardware Class)
N Operating System (operating system class)
n installed Applications (installer class)
N WMI Service Management (WMI service management class)
n Performance Counters (Performance Counter)
Let's introduce the role of these subclasses and its main members.
Computer System Hardware
Computer System Hardware contains classes related to hardware information, such as Win32_CDROMDRIVE, WIN32_DISKDRIVE, WIN32_BIOS, WIN32_NETWORKADAPTER, etc., we can know the hardware of this computer, at this time, at this time Information, such as we get an instantiation of the Win32_DiskDrive class of the current computer through the WQL method, you can know the name of the current computer's disk drive, its device number, its model, and its capacity. The following is the program Way to get the above information:
*********************************************************** ***
// MSDN definition of win32_diskdrive class ...
Class Win32_DiskDrive: CIM_DISKDRIVE
{
String DeviceId;
String model;
String name;
UINT64 SIZE;
......
}
*********************************************************** ***
/ / Get the properties of the local disk drive
Public static void fetchdiskdiVeproperty ()
{
ManagementObjectSearcher Searcher = New ManagementObjectSearcher ("Select * from win32_diskdrive);
Foreach (ManagementObject DiskDrives In Searcher.get ())
{
Console.writeline ("DiskDrives Name =" DiskDrives ["Name"]); console.writeline ("DiskDrives DeviceID =" DiskDrives ["DeviceID"]);
Console.WriteLine ("DiskDrives Model =" DiskDrives ["Model"]);
Console.writeline ("DiskDrives Size =" DiskDrives ["Size"]);
}
}
*********************************************************** ***
// The above code is informing the information informing the management object through the WQL mode.
*********************************************************** ***
Performance Counters
The Operating System subclass contains class members related to the operating system, such as Win32_comapplication, win32_environment, win32_diskpaart, win32_pagefile, win32_bootconfiguration, win32_process, etc., by using the above, we can get partition information, system, system, system, system The page file is placed, the system's startup information, and the information of the thread running in the current system. Like the WIN32_DISKDRIVE class in the Computer System Hardware subclass, we can also get its properties (WQL method query, She is the same, but for the except for the attributes like Win32_Process, it is not possible to call its functions directly through the above way. How to use other objects to call it. Specifically, call this The function will be given in the next section.
Installed Applications
The Installed Applications subclass contains systems related to Windows Installer mode installation software, such as Win32_binary, Win32_registryAction class, etc. , Installable files, information to write registry, etc. The method of the object's properties is the same, that is, query operations through the WQL mode.
WMI Service Management
The WMI Service Management subclass has a class related to the management of WMI services. These classes are used to manage WMI services, which is not used to manage computer systems or organize networks, and its tasks include configuring WMI, manage WMI. Operation, make it in the best working state. Its members are not much, only three, win32_methodparameterclass, win32_wmisetting, win32_wmielementsetting.
Performance Counters
Performance counters members of the class includes a subclass of system performance counter data and performance counter data formatted as Win32_PerfFormattedData_PerfOS_Memory, Win32_PerfRawData_PerfOS_Memory, Win32_PerfFormattedData_PerfProc_Process, Win32_PerfFormattedData_Tcpip_TCP etc. We might get the system performance we want to get through this in an instance of an object Data, and can display data in different forms according to your own needs.