VariantToBooleanArrayAlloc function (propvarutil.h)

Allocates an array of BOOL values then extracts data from a VARIANT structure into that array.

Syntax

PSSTDAPI VariantToBooleanArrayAlloc(
  [in]  REFVARIANT var,
  [out] BOOL       **pprgf,
  [out] ULONG      *pcElem
);

Parameters

[in] var

Type: REFVARIANT

Reference to a source VARIANT structure.

[out] pprgf

Type: BOOL**

When this function returns, contains a pointer to an array of BOOL values extracted from the source VARIANT structure.

[out] pcElem

Type: ULONG*

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

Return value

Type: HRESULT

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

Remarks

This helper function is used when the calling application expects a VARIANT to hold an array of BOOL values.

If the source VARIANT is of type VT_ARRAY | VT_BOOL, this function extracts an array of BOOL values into a newly allocated array. The calling application is responsible for using CoTaskMemFree to release the array pointed to by pprgf when it is no longer needed.

Examples

The following example, to be included as part of a larger program, demonstrates how to use VariantToBooleanArrayAlloc to access an array of BOOL values stored in a VARIANT structure.

// VARIANT var;
// Assume variable var is initialized and valid. 
// The application expects var to contain an array of BOOL values.
BOOL *prgFlags;
ULONG cElems;

HRESULT hr = VariantToBooleanArrayAlloc(var, &prgFlags, &cElems);

if (SUCCEEDED(hr))
{
     // prgFlags now points to a vector of cElems BOOLs.
     CoTaskMemFree(prgFlags);
}

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

VariantToBooleanArray