FILETIME structure
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 |
|
See also
Send comments about this topic to Microsoft
Build date: 9/7/2011
- 11/9/2011
- peterchen!
- 9/29/2011
- chrisrus
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.
- 10/23/2008
- Staffan cronstrom LKP
- 8/16/2009
- mszl
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.
- 5/9/2009
- Thomas Lee
[StructLayout(LayoutKind.Sequential)]
public struct FILETIME
{
public uint dwLowDateTime;
public uint dwHighDateTime;
}
