Skip to content

Latest commit

 

History

History
192 lines (142 loc) · 5.99 KB

nf-propvarutil-propvarianttostringvector.md

File metadata and controls

192 lines (142 loc) · 5.99 KB
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.
PropVariantToStringVector
PropVariantToStringVector function [Windows Properties]
_shell_PropVariantToStringVector
properties.PropVariantToStringVector
propvarutil/PropVariantToStringVector
shell.PropVariantToStringVector
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
PropVariantToStringVector
propvarutil/PropVariantToStringVector
c++
APIRef
kbSyntax
DllExport
Propsys.dll
PropVariantToStringVector

PropVariantToStringVector function

-description

Extracts a vector of strings from a PROPVARIANT structure.

-parameters

-param propvar [in]

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

-param prgsz [out]

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.

-param crgsz [in]

Type: ULONG

Size of the buffer pointed to by prgsz, in elements.

-param pcElem [out]

Type: ULONG*

When this function returns, contains the count of strings extracted from source PROPVARIANT structure.

-returns

Type: HRESULT

This function can return one of these values.

Return code Description
S_OK
Returns S_OK if successful, or an error value otherwise.
TYPE_E_BUFFERTOOSMALL
The sourcePROPVARIANT contained more than crgsz values. The buffer pointed to by prgsz.
E_INVALIDARG
ThePROPVARIANT was not of the appropriate type.

-remarks

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
If the source PROPVARIANT has a supported type, this helper function extracts up to crgsz string values and places an allocated copy of each into the buffer pointed to by prgsz. If the PROPVARIANT contains more elements than will fit into the prgsz buffer, this function returns an error and sets pcElem to 0.

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.

Examples

// 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]);
    }
}

-see-also

InitPropVariantFromStringVector

PropVariantGetStringElem

PropVariantToString

PropVariantToStringVectorAlloc

VariantToStringArray