IWbemClassObject::PutMethod method

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

wszName [in]

The method name that is created.

lFlags [in]

Reserved. This parameter must be 0 (zero).

pInSignature [in]

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.

pOutSignature [in]

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 table lists the value contained within an HRESULT.

Return codeDescription
WBEM_S_NO_ERROR

The call was successful.

WBEM_E_INVALID_DUPLICATE_PARAMETER

The [in, out] method parameter specified in both pInSignature and pOutSignature parameter objects have different qualifiers.

WBEM_E_INVALID_PARAMETER

One or more parameters were not valid.

WBEM_E_MISSING_PARAMETER_ID

Any method parameter (in/out) that is missing the specification of the ID qualifier.

WBEM_E_NONCONSECUTIVE_PARAMETER_IDS

The ID series that is assigned to the method parameters and not consecutive or does not start at 0 (zero).

WBEM_E_PARAMETER_ID_ON_RETVAL

Return value for a method has an ID qualifier.

WBEM_E_PROPAGATED_METHOD

An attempt was made to reuse an existing method name from a parent class and the signatures did not match.

 

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.

Note  The caller must call IWbemClassObject::Release on the pInSignature and pOutSignature pointers when these objects are no longer required.

Examples

For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For C++ code examples, see WMI C++ Application Examples.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Wbemcli.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

CIMWin32.dll;
Esscli.dll;
Evntrprv.dll;
Fastprox.dll;
Framedyn.dll;
Krnlprov.dll;
Ncprov.dll;
Wbemcore.dll;
Wbemess.dll;
Wmipiprt.dll

See also

IWbemClassObject
Creating a Method
IWbemClassObject::GetMethod

 

 

Show:
© 2014 Microsoft. All rights reserved.