WMI Tools

[Previous] [Next]

Various tools are available when you're working with WMI. The two tools you will probably use most often are CIM Studio and the MOF compiler. Later in this chapter in the section titled "The TimeServiceProvider Sample WMI Provider," we'll discuss another tool called the WMI Provider Code Generator Wizard.

WMI CIM Studio

WMI CIM Studio is a tool for viewing and editing the class and instance information for a CIM repository. Classes and instances are grouped into units called namespaces. WMI provides a namespace called root\CIMV2, which contains all the classes and instances that represent a system. To experiment with WMI, install the WMI SDK (specifically, WMI Tools, which is included as part of the Platform SDK on the companion CD). After you install the SDK, you can use the CIM Studio tool to look at the contents of the root\CIMV2 namespace. I will be using CIM Studio in this chapter to show you many of WMI's capabilities.

To open CIM Studio, select WMI CIM Studio from the Programs menu. It will be listed under the Microsoft Platform SDK group (or the WMI SDK group). To see a list of the services installed on your machine, navigate to the Win32_Service class by opening CIM_ManagedSystemElement, CIM_ LogicalElement, CIM_Service, Win32_BaseService, and Win32_Service. Click the Instances toolbar button above the right pane, and you should see the screen shown in Figure 8-2.

click to view at full size.

Figure 8-2. WMI CIM Studio showing installed services

MOF Compiler

A MOF compiler is provided as a part of WMI and can be used to introduce new classes and instances into the system. The following MOF example illustrates a number of features of WMI classes:

 [static] class Msft_Joke {    [key] string JokeName;          string JokeText; }; instance of Msft_Joke {    JokeName = "KnockKnock1";    JokeText = "Knock, knock. :Who's there? Dwayne: Dwayne, who?: "       "Dwayne the bathtub, I'm dwowning!"; }; 

Classes are identified by the keyword class and can be preceded by qualifiers in square brackets ([ ]). Qualifiers are used to supply information relevant to the handling of the class, such as how it's implemented or localization information. Class properties are defined as a type followed by a name and optionally preceded by qualifiers in brackets.

In the Msft_Joke example, the class is defined as [static], meaning that the instances of the class are stored in the WMI repository. The JokeName property is of type string and is a key for the class, which means that every instance of the class must have a value for the property, and the value must be different from the value present in all other instances.



Programming Server-Side Applications for Microsoft Windows 2000
Programming Server-Side Applications for Microsoft Windows 2000 (Microsoft Programming)
ISBN: 0735607532
EAN: 2147483647
Year: 2000
Pages: 126

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net