PropVariantToGUID function
Extracts a GUID value from a PROPVARIANT structure.
Syntax
HRESULT PropVariantToGUID( _In_ REFPROPVARIANT propvarIn, _Out_ GUID *pguid );
Parameters
- propvarIn [in]
-
Type: REFPROPVARIANT
Reference to a source PROPVARIANT structure.
- pguid [out]
-
Type: GUID*
When this function returns, contains the extracted property value if one exists.
Return value
Type: HRESULT
If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
This helper function works forPROPVARIANTstructures of the following types:
- VT_GUID
- VT_BSTR
- VT_LPWSTR
- VT_ARRAY | VT_UI1
PropVariantToGUID is used in places where the calling application expects a PROPVARIANT to hold a single GUID or GUID value. For instance, an application obtaining values from a property store can use this to safely extract the GUID value for GUID properties.
Examples
// IPropertyStore *ppropstore; // Assume variable ppropstore is initialized and valid PROPVARIANT propvar = {0}; HRESULT hr = ppropstore->GetValue(PKEY_Sync_HandlerCollectionID, &propvar); if (SUCCEEDED(hr)) { // PKEY_Sync_HandlerCollectionID is expected to produce a VT_CLSID or VT_EMPTY value. // PropVariantToGUID will convert VT_EMPTY to a failure code. GUID guidCollectionID; hr = PropVariantToGUID(propvar, &guidCollectionID); if (SUCCEEDED(hr)) { // guidCollectionID is now valid } else { // the extraction failed } PropVariantClear(&propvar); }
Requirements
|
Minimum supported client |
Windows XP with SP2, Windows Vista [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2003 with SP1 [desktop apps only] |
|
Redistributable |
Windows Desktop Search (WDS) 3.0 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also