DWbemClassObject.Put

[This is preliminary documentation and subject to change.]

The DWbemClassObject.Put method sets a named property to a new value. This method always overwrites the current value with the new one.

DWbemClassObject.Put(
  [in] Name  As String, 
  [in] lFlags  As Long,
  [in] pVal  As VARIANT,
  [in] vtType  As Long 
) As Long
 

Parameters

Name
String that contains the name of the property to be set. This cannot be vbNullString.
lFlags
Reserved. It must be zero.
pVal
VARIANT which becomes the new property value. If pVal is NULL, the property is set to NULL.

Note  

If pVal is NULL, the type of the property is inferred from the vtType parameter.

vtType
Use this parameter only when pVal is NULL. In such a case, the vtType parameter specifies a COM type of the property. In every other case, vtType must be zero. vtType must also be zero whenever the underlying object is an instance (even if pVal is NULL), since the type of the property is fixed and cannot be changed. In other words, vtType is used only if pVal is NULL, and the underlying object is a class.

Return Values

WBEM_E_FAILED Unspecified error.
WBEM_E_INVALID_PARAMETER An invalid parameter was specified, or the namespace could not be parsed.
WBEM_E_INVALID_PROPERTY_TYPE Property type is not recognized.
WBEM_E_OUT_OF_MEMORY There was not enough memory to complete the operation.
WBEM_E_TYPE_MISMATCH For instances, this error code indicates that the pVal parameter is a VARIANT of an incorrect type for the property. For class definitions, this returns if the property already exists in the parent class, and the new COM type is different from the old COM type. Such properties are read-only for the derived class.
WBEM_NO_ERROR Success.

Remarks

If the property exists in the superclass, its default value is changed unless it is a type mismatch. If the property does not exist and it is not a type mismatch, the property is created.

When you execute this method on an instance, there will always be an overwrite. This is because the property always exists.

When you create a new class, and the underlying type of the property is an object reference, a date/time string, or other special type, it might be necessary to modify the CIMTYPE qualifier for the property to show the special new class. When you modify properties of an instance, set the qualifiers to the correct values ahead of time.

You can only write system properties when you create a new class. In that case, the name of the class you create is designated when you write it to the system property __CLASS.

See Also

System Classes, Properties, and Qualifiers