PropVariantGetInt32Elem function (propvarutil.h)

Extracts a single Int32 element from a PROPVARIANT of type VT_I4, VT_VECTOR | VT_I4, or VT_ARRAY | VT_I4.

Syntax

PSSTDAPI PropVariantGetInt32Elem(
  REFPROPVARIANT propvar,
  ULONG          iElem,
  LONG           *pnVal
);

Parameters

propvar

Type: REFPROPVARIANT

Reference to the source PROPVARIANT structure.

iElem

Type: ULONG

The vector or array index; otherwise, iElem must be 0.

pnVal

Type: LONG*

When this function, contains the extracted Int32 value.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

This helper function works for PROPVARIANT structures of the following types:

  • VT_I4
  • VT_VECTTOR | VT_I4
  • VT_ARRAY | VT_I4
If the source PROPVARIANT has type VT_I4, iElem must be 0. Otherwise, iElem must be less than the number of elements in the vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.

Examples

The following example uses this PropVariantGetInt32Elem with an interation statement to access the values in a PROPVARIANT structure.

// PROPVARIANT propvar;
// assume propvar is initialized and valid

if ((propvar.vt & VT_TYPEMASK) == VT_I4)
{
    UINT cElem = PropVariantGetElementCount(propvar);
    HRESULT hr = <mark type="const">S_OK</mark>;

    for (UINT iElem = 0; SUCCEEDED(hr) && iElem < cElem; iElem ++)
    {
        LONG nValue;
        hr = PropVariantGetInt32Elem(propvar, iElem, &nValue);

        if (SUCCEEDED(hr))
        {
            // nValue is valid now
        }
    }
}

Requirements

   
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

PropVariantGetElem