PropVariantGetBooleanElem function (propvarutil.h)

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

Syntax

PSSTDAPI PropVariantGetBooleanElem(
  [in]  REFPROPVARIANT propvar,
  [in]  ULONG          iElem,
  [out] BOOL           *pfVal
);

Parameters

[in] propvar

Type: REFPROPVARIANT

A reference to the source PROPVARIANT structure.

[in] iElem

Type: ULONG

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

[out] pfVal

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

Requirement Value
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