VariantToBooleanArray function (propvarutil.h)

Extracts an array of Boolean values from a VARIANT structure.

Syntax

PSSTDAPI VariantToBooleanArray(
  [in]  REFVARIANT var,
  [out] BOOL       *prgf,
  [in]  ULONG      crgn,
  [out] ULONG      *pcElem
);

Parameters

[in] var

Type: REFVARIANT

Reference to a source VARIANT structure.

[out] prgf

Type: BOOL*

Pointer to a buffer that contains crgn Boolean values. When this function returns, the buffer has been initialized with *pcElem BOOL elements extracted from the source VARIANT structure.

[in] crgn

Type: ULONG

The number of elements in the buffer pointed to by prgf.

[out] pcElem

Type: ULONG*

When this function returns, contains a pointer to the count of BOOL elements extracted from the source VARIANT structure.

Return value

Type: HRESULT

Returns S_OK if successful, or an error value otherwise, including the following:

Return code Description
TYPE_E_BUFFERTOOSMALL
The source VARIANT contained more than crgn values.
E_INVALIDARG
The VARIANT was not of the appropriate type.

Remarks

This helper function is used when the calling application expects a VARIANT to hold an array that consists of a fixed number of Boolean values.

If the source VARIANT is of type VT_ARRAY | VT_BOOL, this function extracts up to crgn BOOL values and places them into the buffer pointed to by prgf. If the VARIANT contains more elements than will fit into the prgf 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 VariantToBooleanArray to access an array of BOOL values stored in a VARIANT structure.

// VARIANT var;
// Assume variable var is initialized and valid
BOOL rgFlags[4]; // The application is expecting var to hold 4 BOOLs in an array.
ULONG cFlags;

HRESULT hr = VariantToBooleanArray(var, rgFlags, ARRAYSIZE(rgFlags), &cFlags);

if (SUCCEEDED(hr))
{
    if (cFlags == ARRAYSIZE(rgFlags))
    {
        // The application got 4 flag values which are now stored in rgFlags.
    }
    else
    {
        // The application got cFlags which are stored in the first cFlags 
        // elements of rgFlags.
    }
}

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

InitVariantFromBooleanArray

PropVariantToBooleanVector

VariantGetBooleanElem

VariantToBoolean

VariantToBooleanArrayAlloc