This function asks a property bag to read a named property as a string.


SHPropertyBag_ReadStr (
    IPropertyBag *ppb,
    LPCWSTR pszPropName,
    LPWSTR pszBuffer,
    int cchBuffer);


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 pszBuffer argument provides the address of a buffer that is to receive the property value as a null-terminated Unicode string.

The cchBuffer argument provides the capacity of the buffer, in characters.

Return Value

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


If any of the ppb, pszPropName and pszBuffer arguments are NULL, the function fails, with E_INVALIDARG as the error code. If the function cannot read the named property as a VT_BSTR type (using SHPropertyBag_ReadType), it fails, with E_FAIL as the error code. If a string value is obtained, the function copies to the given buffer only as many characters as will fit with a null terminator.


The SHPropertyBag_ReadStr function is exported from SHLWAPI as ordinal 494 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.