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


SHPropertyBag_ReadGUID (
    IPropertyBag *ppb,
    LPCWSTR pszPropName,
    LPGUID pGuid);


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 pGuid argument provides the address of a 16-byte buffer that is to receive the property value as a GUID.

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_EMPTY type (using SHPropertyBag_ReadType), it fails.

If the value is obtained as an array of VT_UI1 types, then the function copies the first 16 bytes of the array as the GUID (without checking that the array has as many as 16 bytes). If the value is obtained as a VT_BSTR type, the function attempts to convert from the usual string representation in braces. If the string is not in this form, the function fails, with E_FAIL as the error code. If the value is obtained as any other type, the function succeeds, but without obtaining a GUID.


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