rudi Posted September 7, 2018 Posted September 7, 2018 (edited) Hello, Propably not an absolute clean approach, (not checking/caring about little / big endian), but it's doing, what I need: Return the last modified time stamp including the milliseconds: #include <Date.au3> $file = "c:\temp\test.txt" ; file must already exist $TSLastModMs = GetFileLastModWithMs($file) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $TSLastModMs = ' & $TSLastModMs & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Func GetFileLastModWithMs($_FullFilePathName) local $h = _WinAPI_CreateFile($_FullFilePathName, 2, 2) local $aTS = _Date_Time_GetFileTime($h) _WinAPI_CloseHandle($h) local $aDate = _Date_Time_FileTimeToArray($aTS[2]) ; [2] = LastModified Return StringFormat("%04d-%02d-%02d %02d:%02d:%02d.%03d", $aDate[2], $aDate[0], $aDate[1], $aDate[3], $aDate[4], $aDate[5], $aDate[6]) EndFunc ;==>GetFileLastModWithMs >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:C:\temp\filetime.au3 +>12:10:00 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\filetime.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop @@ Debug(8) : $TSLastModMs = 2018-09-07 10:09:54.073 >Error code: 0 +>12:10:00 AutoIt3.exe ended.rc:0 +>12:10:00 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.9068 Regards, Rudi. --- original posting - what was my problem, below --- doing some search I found postings, stating that 2s will be the smallest time resolution for filegettime(). 2s seem to be fact for FAT as FS, NTFS has a much finer granularity. This posting states, that NTFS has a granularity of 100ns: https://superuser.com/questions/937380/get-creation-time-of-file-in-milliseconds is it possible to get more than just the "second" information? The reason, why I need this is, that I need to sort files by their creation sequence, and it can happen, that two files are created within the same second, so I cannot resolve their creation order without "millsecond info". Regards, Rudi. edit: I just tried PowerShell, there it's possible to retrieve even more than millisecond information: Millisecond : 336 Ticks : 636719150403363219 TimeOfDay : 11:04:00.3363219 PS C:\Users\Rudi> echo test > test.txt PS C:\Users\Rudi> $(Get-ChildItem .\test.txt).creationtime | format-list Date : 07.09.2018 00:00:00 Day : 7 DayOfWeek : Friday DayOfYear : 250 Hour : 11 Kind : Local Millisecond : 336 Minute : 4 Month : 9 Second : 0 Ticks : 636719150403363219 TimeOfDay : 11:04:00.3363219 Year : 2018 DateTime : Freitag, 7. September 2018 11:04:00 regards, Rudi. Edited September 7, 2018 by rudi dogisay 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE!
rudi Posted September 7, 2018 Author Posted September 7, 2018 I just noticed, that there is a Function called Date_Time_GetFileTime(), that is returning a 3 elements array of $tagFILETIME, the function _Date_Time_FileTimeToStr() converts this to a human readable time stap, but also with just a granularity of seconds. $tagFILENAME is something non printable. The help file is telling something about parameters "hi" and "lo", no clue, how to use parameters with a $Variable? "struct; dword Lo;dword Hi; endstruct" $tagFILETIME Contains the number of 100-nanosecond intervals since January 1, 1601 Global Const $tagFILETIME = "struct; dword Lo;dword Hi; endstruct" Parameters Lo The low order part of the file time Hi The high order part of the file time #include <Date.au3> $file="c:\temp\test.txt" $h=_WinAPI_CreateFile ( $file, 2 ,2) ; open existing file for reading $aTS=_Date_Time_GetFileTime($h) _WinAPI_CloseHandle($h) for $a = 0 to 2 ConsoleWrite("""" & $aTS[$a] & """" & @CRLF) ConsoleWrite(_Date_Time_FileTimeToStr($aTS[$a] )& @CRLF) Next regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
FrancescoDiMuro Posted September 7, 2018 Posted September 7, 2018 1 hour ago, rudi said: $tagFILENAME is something non printable. The help file is telling something about parameters "hi" and "lo", no clue, how to use parameters with a $Variable? Did you try with DllStructGetData() ? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
rudi Posted September 9, 2018 Author Posted September 9, 2018 @FrancescoDiMuro ...try ... DllStructGetData() ? No. Maybe I should take a look at it. Anyway, as the updated, upper part of my OP is reflecting already, I've modified some code taken from Date.au3 Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now