Export (0) Print
Expand All
Expand Minimize

PropVariantToFileTime function

Extracts the FILETIME structure from a PROPVARIANT structure.

Syntax


HRESULT PropVariantToFileTime(
  _In_   REFPROPVARIANT propvar,
  _In_   PSTIME_FLAGS pstfOut,
  _Out_  FILETIME *pftOut
);

Parameters

propvar [in]

Type: REFPROPVARIANT

Reference to a source PROPVARIANT structure.

pstfOut [in]

Type: PSTIME_FLAGS

Specifies one of the following time flags.

PSTF_UTC (0)

Indicates the output will use coordinated universal time.

PSTF_LOCAL (1)

Indicates the output will use local time.

pftOut [out]

Type: FILETIME*

When this function returns, contains the extracted FILETIME structure.

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 in places where the calling application expects a PROPVARIANT to hold a single filetime value. For instance, an application obtaining values from a property store can use this to safely extract a filetime value for filetime properties.

If the source PROPVARIANT has type VT_FILETIME or VT_DATE, this helper function extracts the value as a FILETIME using the timezone specified by pstfOut. If the source PROPVARIANT is VT_EMPTY or any other type, this function returns a failure result.

The source PROPVARIANT must be in Coordinated Universal Time (UTC). The PSTF_UTC and PSTF_LOCAL flags allow the calling application to specify what time zone the output should be converted to.

Examples

The following example, to be included as part of a larger program, demonstrates how to use PropVariantToFileTime to access a FILETIME value in a PROPVARIANT.


// IPropertyStore *ppropstore;
// Assume variable ppropstore is initialized and valid
PROPVARIANT propvar = {0};
HRESULT hr = ppropstore->GetValue(PKEY_DateModified, &propvar);
if (SUCCEEDED(hr))
{
     // PKEY_DateModified is expected to produce a VT_FILETIME or VT_EMPTY value.
     // PropVariantToFileTime will return a failure code for VT_EMPTY
     FILETIME ftModified;
     hr = PropVariantToFileTime(propvar, PSTF_UTC, &ftModified);
     if (SUCCEEDED(hr))
     {
        // ftModified is now valid and contains a file time in UTC
     }
     else
     {
        // Unable to convert propvar to a FILETIME
     }
     PropVariantClear(&propvar);
}

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

InitPropVariantFromFileTime
PropVariantToFileTimeVector
VariantToFileTime
PropVariantChangeType

 

 

Community Additions

ADD
Show:
© 2015 Microsoft