WMI technology application

zhaozj2021-02-16  50

Windows Management Specification (WMI) is a scalable system management structure that uses a unified, standard, scalable-oriented interface. WMI provides you with standard methods for interacting with system management information and basic WMI API. WMI is mainly used by system management application developers and administrators to access and operating system management information. WMI can be used to generate tools for organization and management system information, enabling administrators or system managers to monitor system activities more closely. For example, you can use WMI to develop an application that calls administrators when the web server crashes.

Use the WMI with the .NET framework

WMI provides a large number of specifications to achieve almost any management tasks for many high-end applications (eg, Microsoft Exchange, Microsoft SQL Server, and Microsoft Internet Information Services (IIS)). Administrators can do the following tasks:

Monitor the health of the application. Detect bottlenecks or malfunctions. Manage and configure applications. Query application data (traversal and query using object relationships). Perform seamless local or remote management operations.

The WMI structure consists of the following three layers:

The client uses the WMI execution operation (for example, reading the software component of the management details, configuring the system, and subscription events). Object Manager Provides an intermediate device between the client and the client, which provides some key services, such as standard event publishing and subscription, event filtering, query engine, etc. Provide program software components that capture real-time data and return it to the client application to handle methods from the client call and connect the client to the underlying structure.

Data and events are seamlessly provided to the client and applications through a well-defined architecture. In the .NET framework, System.Management namespaces provide public classes used to traverse WMI architectures.

In addition to the .NET framework, you need to install WMI on your computer to use the management functions in this namespace. If you are using Windows Millennium Edition, Windows 2000 or Windows XP, WMI has been installed. Otherwise, WMI will be downloaded from MSDN.

Access management information with System.Management

The system.management namespace is WMI namespace in the .NET framework. This namespace includes the first class object that supports WMI operations:

ManagementObject or ManagementClass: Single management object or class separately. ManagementObjectSearcher: Used to retrieve the collection of ManagementObject or Management or Management Class objects based on the specified query or enumerate. Managementeventwatcher: It is used to book event notifications from WMI. ManagementQuery: Used as the basis for all query classes.

The use coding example of the System.Management class is very suitable for the .NET framework environment, and WMI uses a standard base framework when any appropriate time. For example, WMI is widely utilized. NET set class and uses recommended encoding modes, such as "delegate" modes for .NET asynchronous. Therefore, developers using the .NET framework can use their current skills to access management information about the computer or application.

See

Using WMI Management Applications | Collection of Search Management Objects | Query Management Information | Booking and Using Management Event | Method for Performing Management Objects | Remote Processing and Connection Options | Using strong Type Objects

Get CPU serial number code string cpuInfo = ""; // cpu SEQ ID ManagementClass cimobject = new ManagementClass ( "Win32_Processor"); ManagementObjectCollection moc = cimobject.GetInstances (); foreach (ManagementObject mo in moc) {cpuInfo = mo.Properties [ "ProcessorId"] value.ToString ();. Console.WriteLine (cpuInfo); Console.ReadLine ();} NIC hardware address acquisition using System.Management; ... ManagementClass mc = new ManagementClass ( "Win32_NetworkAdapterConfiguration"); ManagementObjectCollection moc = mc.getinstances (); Foreach ("" "" iPEnabled "] == true) console.writeline (" Mac Address / T {0} ", Mo [" Macaddress "] .Tostring ()); mo.dispose ();}}

Get hard IDString HDid; ManagementClass cimobject = new ManagementClass ( "Win32_DiskDrive"); ManagementObjectCollection moc = cimobject.GetInstances ();. Foreach (ManagementObject mo in moc) {HDid = (string) mo.Properties [ "Model"] Value;

Messagebox.show (HDID);

转载请注明原文地址:https://www.9cbs.com/read-25020.html

New Post(0)