Writing an Instance Provider

An instance provider supplies instances of one or more given classes. For example, an instance provider can supply information regarding a CPU or other type of hardware. Because the objects managed by an instance provider tend to change on a regular basis, all instance providers are considered pull providers; that is, a provider that dynamically retrieves information regarding a managed object whenever WMI makes a request for the information. The name comes from the idea that WMI "pulls" the information from the provider on behalf of a client request. Using pull technology, an instance provider can support retrieval, enumeration, modification, deletion, and query processing of a specific instance.

High-performance providers can increase the efficiency of an instance provider or programmatically access the data that appears in System Monitor. For more information, see Making an Instance Provider into a High-Performance Provider.

The following procedure describes how to write an instance provider.

To write an instance provider

  1. Register your provider with WMI.

    Instance providers register with WMI by creating a __Win32Provider instance and an __InstanceProviderRegistration class.

  2. Initialize your provider.

    WMI uses IWbemProviderInit to load and initialize a provider. This is a task common to all providers.

    Note

    Instance providers are strongly encouraged to use the multithreading model "Both".

     

  3. Implement the IWbemServices interface for your provider.

    The IWbemServices interface is the primary interface for an instance provider.

  4. Add any additional code necessary for your provider.

    When designing your provider, you will most likely need to call WMI interfaces. For more information, see Making Calls to WMI.

    When retrieving information for a client, you may need to access the security levels for that client. For more information, see Impersonating a Client.

  5. If necessary, implement the high-performance interface.

    The high-performance interface increases the speed at which the provider can react to requests from WMI.

  6. If necessary, implement support for partial-instance updates.

    As the name implies, a partial-instance update is a technique use to update only part of an instance. For more information about calling a partial instance from a client, see Updating Part of an Instance and Retrieving Part of a WMI Instance.

  7. Replace the preexisting provider with your new code.

    You do not need to perform this step if you do not have a preexisting provider to copy over. For more information, see Updating a Provider.