|
Decoupled Event Consumer Provider
The Decoupled event provider sample code creates an event consumer provider for WMI. An event consumer provider allows event instances to be received based on an events generated by an event provider. The event consumer provider is called when an event instance is generated via an event provider. The event consumer provider is a decoupled provider. A decoupled provider 'decouples' the lifetime of the hosting process from the liftetime of the wmi service, this is distinct from existing 'coupled' providers that are launched by the WMI service through the com activation mechanism. Typically an application or server process is launched and services requests relating to a particular application domain, e.g. database server, mail server, etc. A decoupled provider registers it's ability to handle provider requests, associated with the application domain, during the startup procedure for the application or service; whilst the application or service is not running or registered WMI will not attempt to forward event instances requests associated with the provider.
The sample provider registers to receive a single event class 'SampleEvent ', that is forwarded by the accompanying SDK decoupled event provider.
Building the Provider EXE
The EXE can be
built using Microsoft
Visual C++.
1.
Select File +
Open Workspace
2.
Select the
SdkSample.DSP file
Registering the event class bindings and provider
You must
also compile the MOF in order to make the WMI CIMOM aware of the providers
interest in receiving particular events.
From the command line in the sample installation directory, type the
following:
MOFCOMP ProvReg.MOF
At this point, you can run the executable sdksample.exe in combination
with the event provider sample and here a beep as each event is received.
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.