HOWTO: Use the Win32 API to Access File Dates and Times (188977)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
This article was previously published under Q188977 SUMMARY
Visual FoxPro's FDATE() and FTIME() functions can be used to determine the
date and time that a file was last written. However, the Win32 file system
also stores the creation date and time in addition to the last access date
and time. To find these dates and times, it is necessary to use the Win32
functions GetFileTime(), FileTimeToLocalFileTime() and
FileTimeToSystemTime().
GetFileTime accepts a handle to an open file, and returns FILETIME
structures for the creation time, last access time and last write time. The
FILETIME structure is somewhat difficult to work with, because it contains
two 32-bit values representing the number of 100 nanosecond intervals since
January 1, 1601. Therefore, we want to convert it to a SYSTEMTIME
structure. However, Win32 represents all times internally as Greenwich
times, so you first apply a local timezone correction by calling
FileTimeToLocalFileTime().
Files written by or used by 16-bit Windows or DOS applications may not
store all these date and time values.
The FoxPro function GetFTime() illustrates the use of these calls.
REFERENCES
Win32 API Help; (included with the Platform SDK) topics: "GetFileTime",
"FileTimeToLocalTime", "FileTimeToSystemTime", "SYSTEMTIME" and "FILETIME"
Modification Type: | Minor | Last Reviewed: | 7/13/2004 |
---|
Keywords: | kbcode kbhowto KB188977 |
---|
|