Export (0) Print
Expand All

Creating Parameters Objects in C++

The IWbemServices::ExecMethod or ExecMethodAsync methods require the __PARAMETERS system class as a container in pInParams if the method they are executing has any input arguments.

The following procedure describes how to create an instance of the __PARAMETERS system class to hold parameter information.

Aa389768.wedge(en-us,VS.85).gifTo create an instance of __PARAMETERS

  1. Determine the class path for the class containing the method definition.
  2. Using the class path and the IWbemServices pointer passed in from IWbemProviderInit::Initialize, call IWbemClassObject::GetMethod to retrieve the input and output parameter classes.

    The GetMethod method returns an IWbemClassObject pointer for accessing each of these classes.

  3. Using the IWbemClassObject pointer for the output class, call IWbemClassObject::SpawnInstance to create an instance of the class.
  4. Populate the class instance by setting the properties that correspond to the output values and, if there is a return value for the method, the ReturnValue property.
  5. Pass the __PARAMETERS instance back to the caller through the IWbemObjectSink::Indicate method.

After a method provider determines that the input parameters are correct, the method pointed to by strMethodName might still pass or fail. Some method providers spawn a second thread to implement the method so that the method's actual success or failure ends up being reported to the caller through IWbemObjectSink::SetStatus. Note that IWbemObjectSink::SetStatus does not receive the return code of the provider method. However, it receives the return code of the actual call-return mechanism, and is only useful for verifying that the call occurred or that it failed for mechanical reasons.

Related topics

Calling a Method
IWbemCallResult::GetResultObject
IWbemServices::ExecMethodAsync
IWbemServices::ExecMethod

 

 

Show:
© 2015 Microsoft