Library tutorials & articles
Using WMI From Managed Code
Introduction
Windows Management Instrumentation (WMI) is Microsoft’s implementation of Web-Based Enterprise Management (WBEM), which is the industry standard for unifying the management of distributed computer systems. The WBEM standard includes the Common Information Model (CIM) for describing management information relevant to systems, applications, networks, devices and services. It also defines mechanisms for automating administrative tasks.
WMI can be accessed from C or C++, from Visual Basic, or from any scripting language that has an engine on Windows and is able to handle ActiveX objects. It comes pre-installed on Windows Server 2003, Windows XP, Windows Me and Windows 2000, and can be installed separately on Windows NT or Windows 9x systems.
WMI Architecture
The purpose of WMI is to present a uniform interface to any local or remote applications or scripts that need to access management data from a computer system, network or application. Thanks to WMI, programs do not have to talk to a wide variety of operating system APIs which can be particularly inconvenient for scripting languages.
All WMI interfaces are based on the Component Object Model (COM), however it is possible to access WMI from .NET thanks to the COM Inter-Op mechanism, as our diagram shows.
The main parts of WMI are as follows:
Managed objects and providers: A WMI provider is a COM object that monitors one or more managed objects for WMI. Like a driver, a provider extracts WMI data from a managed object and is responsible for passing messages from WMI back to the managed object. Managed objects can be logical or physical components such as a hard drive, a network adapter, a database system, the operating system itself, a process or an application. An example of a provider is the Win32 provider that handles classes like Win32_Printer, which we’ll use in the sample below.
WMI infrastructure: As a Windows component WMI consists of the Windows Management service, which includes the WMI Core, and the WMI repository. The service acts as an intermediary between the providers and the repository. Only static data about objects, such as the classes defined by the providers, are stored in the repository. Most provider classes are defined in Managed Object Format (MOF) files and then compiled into the WMI repository. The provider also has a DLL file which contains the code needed to implement the classes.
Management applications and scripts: A management application queries management information either by calling the COM API for WMI or through the Scripting API for WMI. Through these, management applications can call methods that instruct or reconfigure a managed object. However the only data or actions available for a managed object are those that a provider supplies.
Related articles
Related discussion
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Chart insertation in a windows form...
by pdhanik (1 replies)
-
Point of Sale Developers: Hardware & C# SDK
by ManiGovindan (7 replies)
-
help with the remote frame buffer protocol from real VNC
by poison (0 replies)
-
Need help making a complete program editable, C# or .net I think
by davelee (1 replies)
Related podcasts
-
A Practical Look at Silverlight 2 Part 1
Now that Silverlight 2 is at the Olympics and making a big splash, we wanted to explore this fascinating technology more. Microsoft Silverlight 2 is a cross-browser, cross-platform, and cross-device plug-in for delivering the next generation of .NET based media experiences and rich interactive ap...
Events coming up
-
Dec
9
GL.net Group Meeting - December 2009
Gloucester, United Kingdom
The beginning of this year holiday season will belong to mocks. Ronnie and Stephen will take us for a tour around exciting world of unit testing.
Comments
Leave a comment
Sign in or Join us (it's free).