FILETIME Structure

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

Syntax

C++
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.

The dwLowDateTime and dwHighDateTime members are typically zero or positive values, unless the function using the FILETIME structure allows different values such as 0xFFFFFFFF. 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: 2/4/2010

Tags :


Community Content

mszl
'FILETIME' in 'union'

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.
Tags : contentbug

dmex
vb.net syntax
<StructLayout(LayoutKind.Sequential)> Public Structure FILETIME
Public dwLowDateTime As UInt32
Public dwHighDateTime As UInt32
End Structure

Tags :

dmex
C# syntax
[StructLayout(LayoutKind.Sequential)]
public struct FILETIME
{
public uint dwLowDateTime;
public uint dwHighDateTime;
}
Tags :

Thomas Lee
Alternative to using unmanaged code

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.


Page view tracker