EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

VariantToBooleanWithDefault function

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

Syntax


BOOL VariantToBooleanWithDefault(
  _In_  REFVARIANT varIn,
  _In_  BOOL fDefault
);

Parameters

varIn [in]

Type: REFVARIANT

Reference to a source VARIANT structure.

fDefault [in]

Type: BOOL

The default value for use where no extractable value exists.

Return value

Type: BOOL

Returns the extracted BOOL value; otherwise, the default value specified in fDefault.

Remarks

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

If the source VARIANT is of type VT_BOOL, this helper extracts the BOOL value.

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

If the source VARIANT is of type VT_EMPTY or a conversion is not possible, then VariantToBooleanWithDefault returns the default value provided by fDefault. 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 VariantToBooleanWithDefault to access a BOOL value stored in a VARIANT structure.


// VARIANT var;
// Assume variable var is initialized and valid.  
// The application expects var to hold a BOOL value.
// The application treats VT_EMPTY as FALSE.

BOOL fValue = VariantToBooleanWithDefault(var, FALSE);

// fValue 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

InitVariantFromBoolean
VariantToBoolean
PropVariantToBoolean
PropVariantChangeType

 

 

커뮤니티 추가 항목

추가
표시:
© 2014 Microsoft