IWbemClassObject::PutMethod method (wbemcli.h)
The IWbemClassObject::PutMethod is used to create a method. This call is only supported if the current object is a CIM class definition. Method manipulation is not available from IWbemClassObject pointers that point to CIM instances.
The user cannot create methods with names that begin or end with an underscore. This is reserved for system classes and properties.
Syntax
HRESULT PutMethod(
[in] LPCWSTR wszName,
[in] long lFlags,
[in] IWbemClassObject *pInSignature,
[in] IWbemClassObject *pOutSignature
);
Parameters
[in] wszName
The method name that is created.
[in] lFlags
Reserved. This parameter must be 0 (zero).
[in] pInSignature
A pointer to a copy of the __Parameters system class that contains the in parameters for the method. This parameter is ignored if set to NULL.
[in] pOutSignature
A pointer to a copy of the __Parameters system class that contains the out parameters for the object. This parameter is ignored if set to NULL.
Return value
This method returns an HRESULT that indicates the status of the method call. The following list lists the value contained within an HRESULT. For general HRESULT values, see System Error Codes.
Remarks
For a method, the in and out parameters are described as properties in IWbemClassObject objects.
For example, consider the following method:
Class MyClass{
[key] string KeyVal;
sint32 PropVal;
sint32 ExampleMethod([in] sint32 Param1, [in] uint32 Param2,
[out] string Param3);
HRESULT ReturnValue;
};
In the previous example, the class has one method. To create the method programmatically, the user calls IWbemClassObject::PutMethod with the pInSignature parameter that points to a copy of the system class __Parameters that contains two properties: Param1 and Param2. The pOutSignature points to a copy of the system class __Parameters that contains two properties: Param3 and ReturnValue.
The ReturnValue property of the object pointed to by pOutSignature determines the method return type. If pOutSignature is set to NULL, the return type is assumed to be VOID.
An [in/out] parameter can be defined by adding the same property to both objects pointed to by the pInSignature and pOutSignature parameters. In this case, the properties share the same ID qualifier value.
Each property in a __Parameters class object other than ReturnValue must have an ID qualifier, a zero-based numeric that identifies the order in which the parameters appear. In this example, Param1 would be 0, Param2 1, and Param3 2. No two parameters can have the same ID value, and no ID value can be skipped. If either condition occurs, IWbemClassObject::PutMethod returns WBEM_E_NONCONSECUTIVE_PARAMETER_IDS.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
Target Platform | Windows |
Header | wbemcli.h (include Wbemidl.h) |
Library | WbemUuid.lib |
DLL | CIMWin32.dll; Esscli.dll; Fastprox.dll; FrameDyn.dll; FrameDynOS.dll; Krnlprov.dll; Ncprov.dll; Wbemcore.dll; Wbemess.dll; Wmipiprt.dll |