Windows Dev Center

Expand Minimize

VariantToDoubleWithDefault function

Extracts a DOUBLE value from a VARIANT structure. If no value exists, then the specified default value is returned.

Syntax


DOUBLE VariantToDoubleWithDefault(
  _In_ REFVARIANT varIn,
  _In_ DOUBLE     dblDefault
);

Parameters

varIn [in]

Type: REFVARIANT

Reference to a source VARIANT structure.

dblDefault [in]

Type: DOUBLE

The default value for use where no extractable value exists.

Return value

Type: DOUBLE

Returns the extracted double value; otherwise, the default value specified in dblDefault.

Remarks

This helper function is used when the calling application expects a VARIANT to hold a DOUBLE value and wants to use a default value if it does not.

If the source VARIANT is of type VT_R8, this helper extracts the DOUBLE value.

If the source VARIANT is not of type VT_R8, the function attempts to convert the value in the VARIANT into a DOUBLE.

If the source VARIANT is of type VT_EMPTY or a conversion is not possible, then VariantToDoubleWithDefault returns the default value provided by dblDefault. See PropVariantChangeType for a list of possible conversions.

Examples

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


// VARIANT var;
// Assume variable var is initialized and valid.
// The application expects var to hold a DOUBLE value.

// The application wants to treat VT_EMPTY as 3.1415.
DOUBLE dblValue = VariantToDoubleWithDefault(var, 3.1415);

// dblValue is now valid.

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

InitVariantFromDouble
VariantToDouble
PropVariantToDouble
PropVariantChangeType

 

 

Community Additions

ADD
Show:
© 2015 Microsoft