VariantToBooleanWithDefault function (propvarutil.h)
Extracts a BOOL value from a VARIANT structure. If no value exists, then the specified default value is returned.
Syntax
PSSTDAPI_(BOOL) VariantToBooleanWithDefault(
[in] REFVARIANT varIn,
[in] BOOL fDefault
);
Parameters
[in] varIn
Type: REFVARIANT
Reference to a source VARIANT structure.
[in] fDefault
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
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 |