Windows Management Instrumentation SDK Sample


InstProv

The InstProv sample code creates a WMI Instance Provider.

 

The instances are defined using an array named MyDefs which is declared in instprov.cpp.  The class is quite simple and consists of a string Key property and an integer property.

 

This sample does not support any updating.

 

 

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 the following:

 

NMAKE /f  “Makefile”

 

From Microsoft Visual C++:

 

1.      Select File + Open Workspace

2.      Select the InstProv.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 InstProv.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 instprov.mof

 

At this point, you should be able to access instances of the InstProvSamp class using WMI tools such as WbemDump, CIM Studio or your own WMI application.

 

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.