Windows Management Instrumentation SDK Sample


ClassProv

The ClassProv sample code creates a WMI Class Provider.  The instances are defined using an array named MyDefs which is declared in classprov.cpp.  The class is quite simple and consists of a string key property and an integer property.

 

Building the Provider DLL

 

The DLL can be built from the command line using NMAKE, or it can be built using Microsoft Visual C++. 

 

From the command line in the sample installation directory type:

 

NMAKE /f "Makefile"

 

From Microsoft Visual C++:

 

1.      Select File + Open Workspace

2.      Select the ClassProv.DSP file

 

 

Registering the DLL and Class

 

1.      The DLL must be registered with COM. From the command line in the sample installation directory, type the following:

 

REGSVR32 ClassProv.dll

 

2.      You must also compile the MOF in order to make the WMI CIMOM aware of the class From the command line in the sample installation directory type the following:

 

MOFCOMP ClassProv.MOF

 

At this point, you should be able to exercise the provider using WMI tools such as WbemDump, CIM Studio or your own WMI application.  You can get the instances of "ClassProvSamp" class, or get the object ClassProvSamp.MyKey="a".

 

General Notes

 

Things to remember when you're building your own WMI provider:

 

1.        WMI interfaces are defined in wbemcli.h and wbemprov.h found in the wmi\include directory.  You may #include both these files by including just wbemidl.h located in the same directory.

 

2.        WMI interface CLSIDs are defined in wbemuuid.lib. If you get unresolved externals in interfaces and CLSIDs, this is what is missing.

 

3.        You'll need to link with oleaut32.lib and ole32.lib to get the needed COM support.

 

4.        In the Link|Output settings, specify 'wWinMainCRTStartup' as the entry point. This is per the Unicode programming instructions.

 

5.        If you're using the makefiles, don't forget to set the Visual C++ environment variables. This is done by running VCVARS32.BAT.


© 1998-2001 Microsoft Corporation. All rights reserved.