Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

VariantToDoubleArray function

Extracts an array of DOUBLE values from a VARIANT structure.

Syntax


HRESULT VariantToDoubleArray(
  _In_  REFVARIANT var,
  _Out_ DOUBLE     *prgn,
  _In_  ULONG      crgn,
  _Out_ ULONG      *pcElem
);

Parameters

var [in]

Type: REFVARIANT

Reference to a source VARIANT structure.

prgn [out]

Type: DOUBLE*

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

crgn [in]

Type: ULONG

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

pcElem [out]

Type: ULONG*

When this function returns, contains the count of DOUBLE 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 codeDescription
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 DOUBLE values.

If the source VARIANT has type VT_ARRAY | VT_DOUBLE, this function extracts up to crgn DOUBLE values and places them into the buffer pointed to by prgn.

If the VARIANT contains more elements than will fit into the prgn 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 VariantToDoubleArray to access a DOUBLE array stored in a VARIANT.


// VARIANT var;
// Assume variable var is initialized and valid.
DOUBLE rgDoubles[4]; // The application expects var to hold 4 DOUBLEs in an array.
ULONG cDoubles;

HRESULT hr = VariantToDoubleArray(var, rgDoubles, ARRAYSIZE(rgDoubles), &cFlags);

if (SUCCEEDED(hr))
{
    if (cFlags == ARRAYSIZE(rgDoubles))
    {
        // The application got 4 DOUBLEs which are now stored in rgDoubles.
    }
    else
    {
        // The application got *pcElem DOUBLEs which are stored in the first 
        // *pcElem elements of rgDoubles.
    }
}

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

VariantToDouble
VariantGetDoubleElem
VariantToDoubleArrayAlloc
InitVariantFromDoubleArray
PropVariantToDoubleVector

 

 

Community Additions

ADD
Show:
© 2015 Microsoft