#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include #include #include #include ConsoleWrite("Modified datetime of this script is " & FileGetTimeExt(@ScriptFullPath, 0, 1) & @CRLF) ConsoleWrite("Created datetime of this script is " & FileGetTimeExt(@ScriptFullPath, 1, 1) & @CRLF) ConsoleWrite("Last accessed datetime of this script is " & FileGetTimeExt(@ScriptFullPath, 2, 1) & @CRLF) Func FileGetTimeExt($filename, $option = 0, $format = 0) ; v1.0 ; Extended FileGetTime function to properly deal with DST (Daylight Saving Time (summertime/wintertime)) on Windows 7+ ; Usage is identical to the FileGetTime. ; ; AutoIt Version: 3.3.14.2 ; This function requires Windows 7 or later. ; ; Requirements to include in your main program: ; #include ; #include ; #include ; #include If $option = Default Then $option = 0 If $format = Default Then $format = 0 Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $ssDir = "", $sDummy1 = "", $sDummy2 = "" _PathSplit($filename, $sDrive, $sDir, $sFileName, $sExtension) ; extend path to full path if filename has no path or a path relative to ScriptDir If $sDrive = "" Then _PathSplit(@ScriptFullPath, $sDrive, $ssDir, $sDummy1, $sDummy2) $sDir = $ssDir & $sDir $filename = _PathMake($sDrive, $sDir, $sFileName, $sExtension) EndIf Local $aTime, $tDate, $tOut[6], $hFile, $tSystem, $tLocal, $tFile FileGetTime($filename, $option, $format) ; test if no error occurs If @error Then Return SetError(@error, 0, "") ; use _WinAPI_CreateFileEx instead of _WinAPI_CreateFile to include directory access without an 'Access is denied' error $hFile = _WinAPI_CreateFileEx($filename, $OPEN_EXISTING, $GENERIC_READ, $FILE_SHARE_READ, $FILE_FLAG_BACKUP_SEMANTICS) Switch $option ; convert FileGetTime option 0 to _Date_Time_GetFileTime option 2, 1 to 0 and 2 to 1 Case 0 $option = 2 ; Last modified (default) Case 1 $option = 0 ; Created Case 2 $option = 1 ; Last accessed EndSwitch $aTime = _Date_Time_GetFileTime($hFile) _WinAPI_CloseHandle($hFile) $aTime = $aTime[$option] $tSystem = _Date_Time_FileTimeToSystemTime($aTime) $tLocal = _Date_Time_SystemTimeToTzSpecificLocalTime($tSystem) $tFile = _Date_Time_SystemTimeToFileTime($tLocal) $tDate = _Date_Time_FileTimeToArray($tFile) $tOut[0] = StringFormat("%04i", $tDate[2]) ; Year $tOut[1] = StringFormat("%02i", $tDate[0]) ; Month $tOut[2] = StringFormat("%02i", $tDate[1]) ; Day $tOut[3] = StringFormat("%02i", $tDate[3]) ; Hour $tOut[4] = StringFormat("%02i", $tDate[4]) ; Minutes $tOut[5] = StringFormat("%02i", $tDate[5]) ; Seconds If $format = 0 Then Return SetError(0, 0, $tOut) Return SetError(0, 0, $tOut[0] & $tOut[1] & $tOut[2] & $tOut[3] & $tOut[4] & $tOut[5]) EndFunc ;==>FileGetTimeExt