VariantToDoubleWithDefault function (propvarutil.h)

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

Syntax

PSSTDAPI_(DOUBLE) VariantToDoubleWithDefault(
  [in] REFVARIANT varIn,
  [in] DOUBLE     dblDefault
);

Parameters

[in] varIn

Type: REFVARIANT

Reference to a source VARIANT structure.

[in] dblDefault

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

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

InitVariantFromDouble

PropVariantChangeType

PropVariantToDouble

VariantToDouble