Windows Management Instrumentation SDK Sample


EventProvider

The EventProvider sample demonstrates a WMI event provider.  EventProvider generates a WMI event of class MyEvent every two seconds.  WMI applications can register to receive these events.  The TempConsumer sample provided with the WMI SDK is a simple example of an application that registers for and displays the MyEvent class events generated by this provider.

 

NOTE:  The EventProvider sample should be built and registered as indicated below prior to using the TempConsumer sample.  Without the EventProvider sample in place, there will be no events for TempConsumer to receive.  Please refer to the TempConsumer sample documentation for instructions on building and using the TempConsumer application.

 

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:

 

NMAKE /f "Makefile"

 

From Microsoft Visual C++:

 

1.      Select File + Open Workspace

2.      Select the EventProvider.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 evprov.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 evprov.mof

 

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.