Bewerken

Delen via


Constructing InParameters Objects and Parsing OutParameters Objects

Normally, direct access is adequate to call a WMI provider method. Direct access means executing a method by using object.method syntax. However, in some cases, direct access cannot be used. Also, calling a provider method asynchronously from a script requires an ExecMethodAsync type of call.

Note

Because the callback to the sink might not be returned at the same authentication level as the client requires, it is recommended that you use semisynchronous instead of asynchronous communication. For more information, see Calling a Method.

 

The order of method input and output parameters is defined in the Managed Object Format (MOF) schema for the method. WMI does not prevent the parameter order from being changed when the class is recompiled by mofcomp. By using an InParameters object, you can avoid problems that result from changed schema because the input parameters are identified by name. The correct parameter can be seen by examining the ID qualifier of each input parameter. The first parameter has an ID value of 0 (zero).

The SWbemObject.ExecMethod_, SWbemObject.ExecMethodAsync_, SWbemServices.ExecMethod, and SWbemServices.ExecMethodAsync methods provide an alternate way to execute a provider method in cases where it is not possible to execute a method directly. For more information, see Manipulating Class and Instance Information.

For more information about parameters, see Constructing InParameters Objects and Parsing OutParameters Objects.