Provider::ExecMethod(constCInstance&,constBSTR,CInstance*,CInstance*,long) method (provider.h)

[The Provider class is part of the WMI Provider Framework which is now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.]

The ExecMethod method is called by WMI to invoke a method on a class or instance.


HRESULT ExecMethod(
  [ref] const CInstance & cInstance,
        const BSTR        bstrMethodName,
        CInstance         *pInParams,
        CInstance         *pOutParams,
        long              lFlags


[ref] cInstance

Key properties of the instance in question if the client called an instance method. If the client called a static method, Instance contains a class object.


Name of the method that is invoked.


Pointer to the method input parameters.


Pointer to the method output parameters.


Bitmask of flags with information about the execute method operation. This is the value specified by the client in the IWbemServices::ExecMethod method. Few clients use the lFlags parameters. You can safely ignore lFlags in most provider implementations.

The following flag is handled by (and filtered out) by WMI:


Return value

The default framework provider implementation of this method returns WBEM_E_PROVIDER_NOT_CAPABLE to the calling method. The IWbemServices::ExecMethod method lists the most common return values, although you can choose to return any COM return code.

Return values for methods may be one of two types:

  • HRESULT is used to indicate WMI type errors: WBEM_E_OUT_OF_MEMORY, WBEM_E_NOT_FOUND, and so on.
  • The return value from the method (such as uint32) returns the result from the method.


WMI calls ExecMethod when a client calls IWbemServices::ExecMethod against your class. Therefore, you must implement ExecMethod if your provider supports one or more methods. The following list describes a common implementation of ExecMethod:

  1. Determine which method the client called by examining the bstrMethodName parameter.
  2. Retrieve the input parameters from the pInParams parameter, using the Get methods from the CInstance class, such as CInstance::GetCHString.

    A method may have input parameters, output parameters, both input and output parameters, or no input or output parameters.

  3. Set the output parameters in the pOutParams parameter, using the Set methods of the CInstance class, such as CInstance::SetByte or CInstance::SetStringArray.

    In addition to declaring the [out] properties as specified in the return declaration, you must also declare the return value for the method, as defined in the ReturnValue property. You do not have to declare a return value if the return value is void.

For more information, see IWbemServices::ExecMethod.


Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header provider.h (include FwCommon.h)
Library FrameDyn.lib
DLL FrameDynOS.dll; FrameDyn.dll