PropVariantToCLSID function
Extracts class identifier (CLSID) property value of a PROPVARIANT structure.
Syntax
HRESULT PropVariantToCLSID( _In_ REFPROPVARIANT propvar, _Out_ CLSID *pclsid );
Parameters
- propvar [in]
-
Type: REFPROPVARIANT
Reference to a source PROPVARIANT structure.
- pclsid [out]
-
Type: CLSID*
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_CLSID
- VT_BSTR
- VT_LPWSTR
- VT_ARRAY | VT_UI1
This is an inline function, with its source code provided in the header. It is not included in any .dll or .lib file.
PropVariantToCLSID is used in places where the calling application expects a PROPVARIANT to hold a single CLSID or GUID value. For instance, an application obtaining values from a property store can use this to safely extract the CLSID value for GUID properties.
Examples
The following example, to be included as part of a larger program, demonstrates how to use PropVariantToCLSID to access a CLSID value in a PROPVARIANT.
// 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. // PropVariantToCLSID will convert VT_EMPTY to a failure code. CLSID clsidCollectionID; hr = PropVariantToCLSID(propvar, &clsidCollectionID); if (SUCCEEDED(hr)) { // clsidCollectionID 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 |
|
See also