Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
Time
Time Reference
Time Structures
 FILETIME structure
FILETIME structure

Applies to: desktop apps | Metro style apps

Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).

Syntax

typedef struct _FILETIME {
  DWORD dwLowDateTime;
  DWORD dwHighDateTime;
} FILETIME, *PFILETIME;

Members

dwLowDateTime

The low-order part of the file time.

dwHighDateTime

The high-order part of the file time.

Remarks

To convert a FILETIME structure into a time that is easy to display to a user, use the FileTimeToSystemTime function.

It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should copy the low- and high-order parts of the file time to a ULARGE_INTEGER structure, perform 64-bit arithmetic on the QuadPart member, and copy the LowPart and HighPart members into the FILETIME structure.

Do not cast a pointer to a FILETIME structure to either a ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows.

Not all file systems can record creation and last access time and not all file systems record them in the same manner. For example, on NT FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour. Therefore, the GetFileTime function may not return the same file time information set using the SetFileTime function. Furthermore, FAT records times on disk in local time. However, NTFS records times on disk in UTC. For more information, see File Times.

A function using the FILETIME structure can allow for values outside of zero or positive values typically specified by the dwLowDateTime and dwHighDateTime members. For example, the SetFileTime function uses 0xFFFFFFFF to specify that a file's previous access time should be preserved. For more information, see the topic for the function you are calling.

Examples

For an example, see Changing a File Time to the Current Time or Retrieving the Last-Write Time.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winbase.h (include Windows.h)

See also

File Times
CompareFileTime
FileTimeToSystemTime
GetFileTime
ULARGE_INTEGER

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
@chrisrus      peterchen!   |   Edit   |   Show History
It only says that *some* API's reserve special values that are not to be interpreted as 0 or positive time.
Tags What's this?: Add a tag
Flag as ContentBug
Structure ... can allow values of zero or positive values (#$#*^ --- WHAT!)      chrisrus   |   Edit   |   Show History
"A function using the FILETIME structure can allow for values outside of zero or positive values typically specified by the dwLowDateTime and dwHighDateTime members. " This sentence is devoid of informational content. What is this supposed to mean? I want to know if there are reserved FILETIME values, what their semantics are and which functions honor these semantics.
Tags What's this?: Add a tag
Flag as ContentBug
'FILETIME' in 'union'      Staffan cronstrom LKP ... mszl   |   Edit   |   Show History

Wouldn't this work (one or all of them)?:

union
{
FILETIME AsFileTime ;
ULARGE_INTEGER AsUlargeInteger ;
} MyFileTime ;


union
{
FILETIME AsFileTime ;
ULONGLONG AsULongLong ;
} MyFileTime ;
r

union
{
FILETIME AsFileTime ;
__Int64 AsInt64 ;
} MyFileTime ;


Why shouldn't I do arithmetics on the FileTime fields (members)?
Is it because a 'FILETIME' not embedded in an appropriate 'union'
is not surely 64-bitsaligned? I assume these unions will, am I wrong?

Best regards

Staffan Cronstrom


[A reply]
The most common reason would be that by doing such, you would probably also do it to a FILETIME in a structure when it is not 64 bit aligned. Having a union or a #pragma align(push/8/pop) argument around the structure definition should make it 64bit aligned, but it is not, by default, defined that way, and thus can be put on 32-bit boundaries.
Alternative to using unmanaged code      Thomas Lee   |   Edit   |   Show History

As an alternative to using this unmaged structure. As an alternative, you might consider using .NET's System.DateTime class, along wiht the ToFileTime and FromFileTime methods.

For more information on the class, see: http://msdn.microsoft.com/en-us/library/system.datetime_methods(VS.85).aspx. For information on the FromFileTime and ToFileTime methods, see: http://msdn.microsoft.com/en-us/library/system.datetime.fromfiletime(VS.85).aspx and http://msdn.microsoft.com/en-us/library/system.datetime.tofiletime(VS.85).aspx respectively.

C# syntax      dmex   |   Edit   |   Show History
[StructLayout(LayoutKind.Sequential)]
public struct FILETIME
{
public uint dwLowDateTime;
public uint dwHighDateTime;
}
Tags What's this?: Add a tag
Flag as ContentBug
vb.net syntax      dmex   |   Edit   |   Show History
<StructLayout(LayoutKind.Sequential)> Public Structure FILETIME
Public dwLowDateTime As UInt32
Public dwHighDateTime As UInt32
End Structure
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker