SHPropertyBag_ReadType

This function asks a property bag to read a named property as an arbitrary type.

Declaration

HRESULT
SHPropertyBag_ReadType (
    IPropertyBag *ppb,
    LPCWSTR pszPropName,
    VARIANT *pVar,
    VARTYPE vt);

Parameters

The ppb argument provides the address of an IPropertyBag interface.

The pszPropName argument provides the address of a null-terminated Unicode string that names the property.

The pVar argument provides the address of a VARIANT that is to receive the property value. Nothing is expected of this structure on input to the function.

The vt argument provides the desired type. Use VT_EMPTY if no particular type is desired.

Return Value

The function returns zero for success, else an error code.

Behaviour

The function calls the given property bag’s Read method, having initialised the given VARIANT and set into it the given type. If the method succeeds but produces the value as some type other than desired, and the desired type is not VT_EMPTY, the function attempts a conversion to the desired type. This is a default conversion through VariantChangeType, except that if the type obtained is VT_BSTR and the type desired is VT_I1, VT_I2, VT_I4, VT_INT, VT_UI1, VT_UI2, VT_UI4 or VT_UINT, the function performs an intermediate conversion to VT_INT or VT_UINT using StrToIntExW so that C-language hexadecimal syntax is respected.

Availability

The SHPropertyBag_ReadType function is exported from SHLWAPI as ordinal 493 in version 6.00.

Though this function dates from 2001, it was still not documented by Microsoft in the MSDN Library at least as late as the CD edition dated January 2004.