PropVariantToInt16VectorAlloc function (propvarutil.h)

Extracts data from a PROPVARIANT structure into a newly allocated Int16 vector.

Syntax

PSSTDAPI PropVariantToInt16VectorAlloc(
  [in]  REFPROPVARIANT propvar,
  [out] SHORT          **pprgn,
  [out] ULONG          *pcElem
);

Parameters

[in] propvar

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

[out] pprgn

Type: SHORT**

When this function returns, contains a pointer to a vector of Int16 values extracted from the source PROPVARIANT structure.

[out] pcElem

Type: ULONG*

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

Return value

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.
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 an Int16 vector value.

If the source PROPVARIANT has type VT_VECTOR | VT_I2 or VT_ARRAY | VT_I2, this function extracts a vector of Int16 values into a newly allocated vector of SHORT values. The calling application is responsible for using CoTaskMemFree to release the vector pointed to by pprgn when it is no longer needed.

Examples

This helper function is used in places where the calling application expects a PROPVARIANT to hold an Int16 vector value.

// PROPVARIANT propvar;
// Assume the variable propvar is initialized and valid. The application is expecting propvar to contain a vector of Int16 values.
SHORT *prgShorts;
ULONG cElems;
HRESULT hr = PropVariantToBooleanVectorAlloc(propvar, & prgShorts, &cElems);
if (SUCCEEDED(hr))
{
     // prgShorts now points to a vector of cElems SHORTs.
     CoTaskMemFree(prgShorts);
}

Requirements

Requirement Value
Minimum supported client Windows XP with SP2, Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 with SP1 [desktop apps only]
Target Platform Windows
Header propvarutil.h
Library Propsys.lib
DLL Propsys.dll (version 6.0 or later)
Redistributable Windows Desktop Search (WDS) 3.0

See also

InitPropVariantFromInt16Vector

PropVariantGetInt16Elem

PropVariantToInt16

PropVariantToInt16Vector

VariantToInt16Array