Export (0) Print
Expand All
Expand Minimize

VariantToBooleanArrayAlloc function

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

Syntax


HRESULT VariantToBooleanArrayAlloc(
  _In_   REFVARIANT var,
  _Out_  BOOL **pprgf,
  _Out_  ULONG *pcElem
);

Parameters

var [in]

Type: REFVARIANT

Reference to a source VARIANT structure.

pprgf [out]

Type: BOOL**

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

pcElem [out]

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

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

VariantToBooleanArray
InitVariantFromBooleanArray
PropVariantToBooleanVector

 

 

Community Additions

ADD
Show:
© 2014 Microsoft