Alternatively, or in conjunction with SKAN's solution above there may be another one that reads
LastWrite time for the selected file. It may be of use, say to check if the file has been tampered with. As long as the file is in its original pristine state the LastWrite timestamp should be the same as the linker timestamp in the PE header.
The following is an AHK adaptation of the example code found
here. Note that the original example uses the safe API
StringCchPrintf() but for the life of me I couldn't get it to work here so I used the older "unsafe" version.
The date/time format of the output string can be changed by modifying the format string (second parameter of
sprintf) and/or the order of the arguments following it (and the size of the
r buffer if necessary). Currently it is in European format:
day.month.year-full hour:minutes:seconds .
Disclaimer: I only tested it with AHK 32bit executable, in WINE under Linux Mint. There may be structure misalignment with 64bit AHK.
Code: Select all
MsgBox % GLMT(A_AhkPath)
GLMT(p)
{
VarSetCapacity(r, 40, 32) ; 19 Unicode chars + NULL
VarSetCapacity(buf, 36, 0) ; WIN32_FILE_ATTRIBUTE_DATA struct
VarSetCapacity(tu, 16, 0) ; SYSTEMTIME struct
if !DllCall("GetFileAttributesEx", "Str", p, "UInt", 0, "Ptr", &buf)
return "Error 1"
if !DllCall("FileTimeToSystemTime", "Ptr", &buf+20, "Ptr", &tu)
return "Error 2"
if !DllCall("msvcrt\sprintf"
, "AStr", r
, "AStr", "%02d.%02d.%04d %02d:%02d:%02d"
, "UShort", NumGet(tu, 6, "UShort") ; day
, "UShort", NumGet(tu, 2, "UShort") ; month
, "UShort", NumGet(tu, 0, "UShort") ; year
, "UShort", NumGet(tu, 8, "UShort") ; hour
, "UShort", NumGet(tu, 10, "UShort") ; minutes
, "UShort", NumGet(tu, 12, "UShort") ; seconds
, "CDecl")
return "Error 3"
return r
}