Windows Management Instrumentation SDK Sample


PropProv

The PropProv sample code creates a dynamic property provider for WMI.  This is the simplest type of provider and this sample just returns some hard-coded property values.

 

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 PropProv.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 PropProv.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 PropProv.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.

 

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.