InitVariantFromBoolean function (propvarutil.h)

Initializes a VARIANT structure with a Boolean value.

Syntax

HRESULT InitVariantFromBoolean(
  [in]  BOOL    fVal,
  [out] VARIANT *pvar
);

Parameters

[in] fVal

Type: BOOL

Source BOOL value.

[out] pvar

Type: VARIANT*

When this function returns, contains the initialized VARIANT structure.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Creates a VT_BOOL variant.

Note that the boolVal structure member initialized by this function is of type VARIANT_BOOL and therefore can have values VARIANT_TRUE or VARIANT_FALSE. When you work with this structure member directly, use these constants instead of TRUE or FALSE because VARIANT_TRUE is not equal to TRUE and sizeof(VARIANT_TRUE) is not the same as sizeof(TRUE).

This is an inline function, with its source code provided in the header. It is not included in any .dll or .lib file.

Examples

The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromBoolean.

VARIANT var;

HRESULT hr = InitVariantFromBoolean(TRUE, &var);

if (SUCCEEDED(hr))
{
    // var now is valid and has type VT_BOOL.
     VariantClear(&propvar);
}

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
Redistributable Windows Desktop Search (WDS) 3.0

See also

InitPropVariantFromBoolean

VariantToBoolean

VariantToBooleanWithDefault