PropVariantGetBooleanElem function

Extracts a single Boolean element from a PROPVARIANT structure of type VT_BOOL, VT_VECTOR | VT_BOOL, or VT_ARRAY | VT_BOOL.

Syntax


HRESULT PropVariantGetBooleanElem(
  _In_  REFPROPVARIANT propvar,
  _In_  ULONG          iElem,
  _Out_ BOOL           *pfVal
);

Parameters

propvar [in]

Type: REFPROPVARIANT

A reference to the source PROPVARIANT structure.

iElem [in]

Type: ULONG

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

pfVal [out]

Type: BOOL*

When this function returns, contains the extracted Boolean value.

Return value

Type: HRESULT

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

Remarks

If the source PROPVARIANT structure has type VT_BOOL, 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.

The following example uses this function to loop through the values in a PROPVARIANT structure.

Examples


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

if ((propvar.vt & VT_TYPEMASK) == VT_BOOL)
{
    UINT cElem = PropVariantGetElementCount(propvar);
    HRESULT hr = <mark type="const">S_OK</mark>;
    
    for (UINT iElem = 0; SUCCEEDED(hr) && iElem < cElem; iElem ++)
    {
        BOOL fValue;
        hr = PropVariantGetBooleanElem(propvar, iElem, &fValue);
    
        if (SUCCEEDED(hr))
        {
            // fValue 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]

Redistributable

Windows Desktop Search (WDS) 3.0

Header

Propvarutil.h

Library

Propsys.lib

DLL

Propsys.dll (version 6.0 or later)

See also

PropVariantGetElem

 

 

Show: