[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
);
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.
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. |
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.
IWbemClassObject::GetPropertyQualifierSet, System Classes, Properties, and Qualifiers