VariantToDosDateTime function (propvarutil.h)

Extracts a date and time value in Microsoft MS-DOS format from a VARIANT structure.

Syntax

PSSTDAPI VariantToDosDateTime(
  [in]  REFVARIANT varIn,
  [out] WORD       *pwDate,
  [out] WORD       *pwTime
);

Parameters

[in] varIn

Type: REFVARIANT

Reference to a source VARIANT structure.

[out] pwDate

Type: WORD*

When this function returns, contains the extracted WORD that represents a MS-DOS date.

[out] pwTime

Type: WORD*

When this function returns, contains the extracted contains the extracted WORD that represents a MS-DOS time.

Return value

Type: HRESULT

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

Remarks

This helper function is used when the calling application expects a VARIANT to hold a datetime value.

If the source VARIANT is of type VT_DATE, this function extracts the datetime value.

If the source VARIANT is not of type VT_DATE, the function attempts to convert the value in the VARIANT structure into the right format. If a conversion is not possible, VariantToDosDateTime returns a failure code. See PropVariantChangeType for a list of possible conversions.

See DosDateTimeToVariantTime for more information about the formats of pwDate, pwTime, and the source datetime value.

Examples

The following example, to be included as part of a larger program, demonstrates how to use VariantToDosDateTime to access a datetime value in a VARIANT.

// VARIANT var;
// Assume variable var is initialize and valid.
// The application expects var to hold a VT_DATE value.

WORD wDate;
WORD wTime;

HRESULT hr = VariantToDosDateTime(var, &wDate, &wTime);

if (SUCCEEDED(hr))
{
    // wDate and wTime are 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

InitVariantFromDosDateTime

PropVariantChangeType

PropVariantToFileTime

VariantToFileTime