Export (0) Print
Expand All

Writing a Method Provider

A method provider allows WMI access to the methods of a class. For example, a class that represents an application may have a method that terminates the application.

Changing the order of method input and output parameters when updating an existing method provider can cause failure for applications that call the method. The order of the input or output parameters is established by the value of the ID qualifier on each parameter. The first parameter has an ID value of zero. Add new input parameters at the end of the existing parameters rather than inserting them in the already established sequence.

The following procedure describes how to implement a method provider.

Aa394613.wedge(en-us,VS.85).gifTo implement a method provider

  1. Design and register your class provider with WMI.

    Class providers register with WMI by creating a __Win32Provider instance and a __MethodProviderRegistration class. For more information, see Registering a Method Provider.

  2. Implement the IWbemProviderInit interface for your provider.

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

  3. Implement the IWbemServices::ExecMethodAsync method for your provider.

    The IWbemServices interface is the primary interface for a method provider. For more information, see Implementing the Primary Interface for a Method 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 Calling a Method and Maintaining Security Levels in a Provider.

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

 

 

Show:
© 2014 Microsoft