UID | title | description | helpviewer_keywords | old-location | tech.root | ms.assetid | ms.date | ms.keywords | req.header | req.include-header | req.target-type | req.target-min-winverclnt | req.target-min-winversvr | req.kmdf-ver | req.umdf-ver | req.ddi-compliance | req.unicode-ansi | req.idl | req.max-support | req.namespace | req.assembly | req.type-library | req.lib | req.dll | req.irql | targetos | req.typenames | req.redist | ms.custom | f1_keywords | dev_langs | topic_type | api_type | api_location | api_name | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NF:propvarutil.PropVariantToStringVector |
PropVariantToStringVector function (propvarutil.h) |
Extracts a vector of strings from a PROPVARIANT structure. |
|
properties\PropVariantToStringVector.htm |
properties |
6618ee02-1939-4c9c-8690-a8cd5d668cdb |
12/05/2018 |
PropVariantToStringVector, PropVariantToStringVector function [Windows Properties], _shell_PropVariantToStringVector, properties.PropVariantToStringVector, propvarutil/PropVariantToStringVector, shell.PropVariantToStringVector |
propvarutil.h |
Windows |
Windows XP with SP2, Windows Vista [desktop apps only] |
Windows Server 2003 with SP1 [desktop apps only] |
Propsys.lib |
Propsys.dll (version 6.0 or later) |
Windows |
Windows Desktop Search (WDS) 3.0 |
19H1 |
|
|
|
|
|
|
Extracts a vector of strings from a PROPVARIANT structure.
Type: REFPROPVARIANT
Reference to a source PROPVARIANT structure.
Type: PWSTR*
Pointer to a vector of string pointers. When this function returns, the buffer has been initialized with pcElem elements pointing to newly allocated strings containing the data extracted from the source PROPVARIANT.
Type: ULONG
Size of the buffer pointed to by prgsz, in elements.
Type: ULONG*
When this function returns, contains the count of strings extracted from source PROPVARIANT structure.
Type: HRESULT
This function can return one of these values.
Return code | Description |
---|---|
|
Returns S_OK if successful, or an error value otherwise. |
|
The sourcePROPVARIANT contained more than crgsz values. The buffer pointed to by prgsz. |
|
ThePROPVARIANT was not of the appropriate type. |
This helper function is used in places where the calling application expects a PROPVARIANT to hold a vector of string values with a fixed number of elements.
This function works for the following PROPVARIANT types:
- VT_VECTOR | VT_LPWSTR
- VT_VECTOR | VT_BSTR
- VT_ARRAY | VT_BSTR
Since each string in pointed to by the output buffer has been newly allocated, the calling application is responsible for using CoTaskMemFree to free each string in the output buffer when they are no longer needed.
If a BSTR in the source PROPVARIANT is NULL, it is converted to a newly allocated string containing "" in the output.
// PROPVARIANT propvar;
// Assume the variable propvar is initialized and valid
LPWSTR rgszStrings; // The application is expecting propvar to hold 4 strings in a vector
ULONG cElems;
HRESULT hr = PropVariantToStringVector(propvar, rgszStrings, ARRAYSIZE(rgszStrings), &cElems);
if (SUCCEEDED(hr))
{
if (cElems == ARRAYSIZE(rgszStrings))
{
// The application got 4 string which are now stored in rgszStrings
}
else
{
// The application got cElems which are stored in the first cElems elements of rgLongs
}
// Free the cElems strings that PropVariantToStringVector allocated
for (ULONG i = 0; i < cElems; i++)
{
CoTaskMemFree(rgszStrings[i]);
}
}
InitPropVariantFromStringVector