Export (0) Print
Expand All
Expand Minimize

PropVariantToInt16Vector function

Extracts a vector of Int16 values from a PROPVARIANT structure.

Syntax


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

Parameters

propvar [in]

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

prgn [out]

Type: SHORT*

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

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 Int16 elements extracted from 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.

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 Int16 vector value with a fixed number of elements.

If the source PROPVARIANT has type VT_VECTOR | VT_I2 or VT_ARRAY | VT_I2, this helper function extracts up to crgn Int16 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


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

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

InitPropVariantFromInt16Vector
PropVariantToInt16
PropVariantGetInt16Elem
PropVariantToInt16VectorAlloc
VariantToInt16Array

 

 

Community Additions

ADD
Show:
© 2015 Microsoft