WMI SDK Sample - Decoupled Instance Provider

Windows Management Instrumentation SDK Sample

Decoupled Instance Provider

The Decoupled instance provider sample code creates an instance provider for WMI. An instance provider allows instances to be retrieved from a dynamic data source. The instance provider is called when a client request requires information relevant to that particular provider. The instance 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 satisfy client requests associated with the provider.

The sample provider supports a single class 'Win32_ProcessEx', that returns static instances that were captured from the existing system class 'Win32_Process'.

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 Class and provider

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