IWbemClassObject::Get

[This is preliminary documentation and subject to change.]

The IWbemClassObject::Get method retrieves the specified property value, if it exists. This method also can return system properties.

HRESULT IWbemClassObject::Get(
  [in] BSTR bstrName,
  [in] long lFlags,
  [out, OPTIONAL] VARIANT *pVal, 
  [out, OPTIONAL] VARTYPE *pvtType,  
  [out, OPTIONAL] long *plFlavor 
);
 

Parameters

bstrName
The desired property name. This must point to a valid BSTR It is treated as read-only.
lFlags
Reserved. It must be zero.
pVal
Points to an existing uninitialized VARIANT structure that receives the property value, if found. Since this is an out-only parameter, this method calls VariantInit on this VARIANT. The pVal parameter can be NULL if a property value is not required. If an error code is returned, the VARIANT pointed to by pVal is left unmodified.

Note  It is required that the caller call VariantClear on the returned VARIANT when its value is no longer required. This will prevent memory leaks in the client process. The type of the VARIANT returned does not always indicate the real COM type of the property. If the property currently has no value (the null value), the VARIANT is of type VT_NULL. Client applications must use the plType parameter to learn the real COM type of the property.

If the type is VT_DISPATCH, the returned property in the VARIANT is an embedded IWbemClassObject. After extracting the IDispatch pointer, the user must call IDispatch::QueryInterface for IID_IWbemClassObject and use the returned pointer to access the embedded IWbemClassObject. Note that VariantClear invokes Release on the object. However, since the user causes an implicit AddRef to occur by calling QueryInterface, the user must explicitly Release the IWbemClassObject pointer retrieved from IDispatch::QueryInterface, as well as call VariantClear on the returned VARIANT.

pvtType
Can be NULL. If not NULL, it receives the COM Automation (VT_BSTR, VT_I4, and so on) type of the property.
plFlavor
Can be NULL. If not NULL, the Long value pointed to receives information on the origin of the property:
WBEM_FLAVOR_ORIGIN_LOCAL
The property belongs to the derived-most class.
WBEM_FLAVOR_ORIGIN_PROPAGATED
The property was inherited from a parent class.
WBEM_FLAVOR_ORIGIN_SYSTEM
The property is a standard system property.

Return Values

WBEM_E_FAILED General failure.
WBEM_E_NOT_FOUND The specified property was not found.
WBEM_E_OUT_OF_MEMORY There was not enough memory to complete the operation.
WBEM_NO_ERROR Success.

Remarks

If the underlying type of the property is an object path, a date/time string, or another special type, the returned values will not contain enough information to identify the true type. In applications where you do not know in advance the true property type, you must retrieve the CIMTYPE qualifier for the specified propertyusing IWbemClassObject::GetPropertyQualifierSet.

Note  When you  create a new object using IWbemClassObject::SpawnInstance, it is important to note that some system properties are not set until the object has been written to CIMOM. In all cases, IWbemClassObject::Get returns the requested system property, but the return value can be NULL.

See Also

IWbemClassObject::GetPropertyQualifierSet, System Classes, Properties, and Qualifiers