Expand Minimize

PropVariantToUInt32Vector function

Extracts data from a PROPVARIANT structure into an ULONG vector.

Syntax


HRESULT PropVariantToUInt32Vector(
  _In_   REFPROPVARIANT propvar,
  _Out_  ULONG *prgn,
  _In_   ULONG crgn,
  _Out_  ULONG *pcElem
);

Parameters

propvar [in]

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

prgn [out]

Type: ULONG*

Points to a buffer containing crgn   ULONG values. When this function returns, the buffer has been initialized with pcElem   ULONG elements extracted from the source PROPVARIANT.

crgn [in]

Type: ULONG

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

pcElem [out]

Type: ULONG*

When this function returns, contains the count of ULONG values 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.

TYPE_E_BUFFERTOOSMALL

The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgn is too small.

E_INVALIDARG

The PROPVARIANT was not of the appropriate type.

 

Remarks

This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of ULONG values with a fixed number of elements.

If the source PROPVARIANT has type VT_VECTOR | VT_UI4 or VT_ARRAY | VT_UI4, this helper function extracts up to crgn   ULONG values and places them into the buffer pointed to by prgn. If the PROPVARIANT contains more elements than will fit into the prgn buffer, this function returns an error and sets pcElem to 0.

Examples

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


// PROPVARIANT propvar;
// Assume the variable propvar is initialized and valid
ULONG rgLongs[4]; // The application is expecting propvar to hold 4 ULONGs in a vector
ULONG cElems;
HRESULT hr = PropVariantToUInt32Vector(propvar, rgLongs, ARRAYSIZE(rgLongs), &cElems);
if (SUCCEEDED(hr))
{
     if (cElems == ARRAYSIZE(rgLongs))
     {
         // The application got 4 ULONGs which are now stored in rgLongs
     }
     else
     {
         // The application got cElems which are stored in the first cElems elements of rgLongs
     }
}

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

InitPropVariantFromUInt32Vector
PropVariantToUInt32
PropVariantGetUInt32Elem
PropVariantToUInt32VectorAlloc
VariantToUInt32Array

 

 

Community Additions

ADD
Show:
© 2014 Microsoft