VariantToDoubleArrayAlloc function (propvarutil.h)

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

Syntax

PSSTDAPI VariantToDoubleArrayAlloc(
  [in]  REFVARIANT var,
  [out] DOUBLE     **pprgn,
  [out] ULONG      *pcElem
);

Parameters

[in] var

Type: REFVARIANT

Reference to a source VARIANT structure.

[out] pprgn

Type: DOUBLE**

When this function returns, contains a pointer to an array of DOUBLE 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 DOUBLE values.

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

Examples

The following example, to be included as part of a larger program, demonstrates how to use VariantToDoubleArrayAlloc to access a DOUBLE array value in a VARIANT.

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

HRESULT hr = VariantToDoubleArrayAlloc(var, &prgDoubles, &cElems);

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

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

InitVariantFromDoubleArray

PropVariantChangeType

PropVariantToDoubleVectorAlloc

VariantToDoubleArray