Export (0) Print
Expand All
Expand Minimize

PropVariantToInt32VectorAlloc function

Extracts data from a PROPVARIANT structure into a newly-allocated Int32 vector.

Syntax


HRESULT PropVariantToInt32VectorAlloc(
  _In_   REFPROPVARIANT propvar,
  _Out_  LONG **pprgn,
  _Out_  ULONG *pcElem
);

Parameters

propvar [in]

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

pprgn [out]

Type: LONG**

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

pcElem [out]

Type: ULONG*

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

Return value

Type: HRESULT

This function can return one of these values.

Return codeDescription
S_OK

Returns S_OK if successful, or an error value otherwise.

E_INVALIDARG

ThePROPVARIANTwas not of the appropriate type.

 

Remarks

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

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

Examples

The following example, to be included as part of a larger program, demonstrates how to use PropVariantToInt32VectorAlloc to access an LONG vector value in a PROPVARIANT.


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

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

Propvarutil.h

Library

Propsys.lib

DLL

Propsys.dll (version 6.0 or later)

See also

InitPropVariantFromInt32Vector
PropVariantToInt32
PropVariantGetInt32Elem
PropVariantToInt32Vector
VariantToInt32Array

 

 

Community Additions

ADD
Show:
© 2014 Microsoft