Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NT File Last Accessed Date?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00254083
Message ID:
00254409
Views:
21
Parameter paFTimes, pcFilename
*-- 
*   lresult = gfiletime( @aTimeArray, cFilename)
*
*   paFTimes - A variable passed by reference, to store three (3) datetimes.
*              1- Creation Date
*              2- Last Access Date
*              3- Last Modification Date
*
*   pcFilename - Full filename string
*--
Local llRetval, lpinfo, lctmutc, lctmlocal, lctmsys

*-- Get Files Attributes
DECLARE INTEGER GetFileAttributesEx IN WIN32API ;
        STRING cFile, INTEGER nlevel, STRING @lpinfo

*-- Convert UTC time to Local time
DECLARE INTEGER FileTimeToLocalFileTime IN WIN32API ;
        STRING cTimeUTC, STRING @cTimeLocal

*-- Convert File time to System time
DECLARE INTEGER FileTimeToSystemTime IN WIN32API ;
        STRING Fltime, STRING @Sytime

If type('paFTimes[1]') = 'U' .Or. ALen(paFTimes, 1) != 3
   *-- Redimension, if var is not a 3 rows array.
   Dimension paFTimes(3)
Endif

llRetval = .t.
lpinfo = Replicate(chr(0), 36)      && WIN32_FILE_ATTRIBUTE_DATA Struct
lctmutc = Replicate(chr(0), 8)      && FILETIME Struct
lctmlocal = Replicate(chr(0), 8)    && FILETIME Struct
lctmsys = Replicate(chr(0), 16)  && SYSTEMTIME Struct

If GetFileAttributesEx(pcFilename, 0, @lpinfo) != 0
    For J=1 To 3
        lctmutc = Substr(lpinfo, 5+ (J-1)* 8, 8)
        FileTimeToLocalFileTime(lctmutc, @lctmlocal)
        FileTimeToSystemTime(lctmlocal, @lctmsys)
        
        *-- Convert SYSTEMTIME structure to Foxpro DATETIME
        paFTimes[J] = DateTime( ;
            Bitlshift(asc(substr(lctmsys, 2, 1)),8) + asc(substr(lctmsys, 1, 1)),  ;
            Bitlshift(asc(substr(lctmsys, 4, 1)),8) + asc(substr(lctmsys, 3, 1)),  ;
            Bitlshift(asc(substr(lctmsys, 8, 1)),8) + asc(substr(lctmsys, 7, 1)),  ;
            Bitlshift(asc(substr(lctmsys, 10, 1)),8) + asc(substr(lctmsys, 9, 1)), ;
            Bitlshift(asc(substr(lctmsys, 12, 1)),8) + asc(substr(lctmsys, 11, 1)),;
            Bitlshift(asc(substr(lctmsys, 14, 1)),8) + asc(substr(lctmsys, 13, 1)) )
    EndFor
Else
    *-- Error
    llRetval = .f.
Endif

Return llRetval

Just an opinion... Not a fact.
Previous
Reply
Map
View

Click here to load this message in the networking platform