InitPropVariantFromBoolean function (propvarutil.h)

Initializes a given PROPVARIANT structure as a VT_BOOL using a specified Boolean value.

Syntax

HRESULT InitPropVariantFromBoolean(
  [in]  BOOL        fVal,
  [out] PROPVARIANT *ppropvar
);

Parameters

[in] fVal

Type: BOOL

Source BOOL value.

[out] ppropvar

Type: PROPVARIANT*

When this function returns, contains the initialized PROPVARIANT structure.

Return value

Type: HRESULT

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

Remarks

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

Note that the boolVal member specifically initialized by this function is of type VARIANT_BOOL and therefore can have values VARIANT_TRUE or VARIANT_FALSE. When working 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).

Examples

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

PROPVARIANT propvar;

HRESULT hr = InitPropVariantFromBoolean(TRUE, &propvar);

if (SUCCEEDED(hr))
{
    // propvar now is valid and has type VT_BOOL.
 
    PropVariantClear(&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

InitPropVariantFromBooleanVector

InitVariantFromBoolean

PropVariantToBoolean