引用以前的帖子:<br>type<br> TFileTimeType = (fttCreation, fttLastAccess, fttLastWrite);<br> //分别对应文件创建时间,访问时间,修改时间<br>function GetFileDateTime(const FileName: string; FileTimeType: TFileTimeType): TDateTime;<br>var<br> Handle: THandle;<br> FindData: TWin32FindData;<br> LocalFileTime: TFileTime;<br> DosDateTime: Integer;<br>begin<br> Handle := FindFirstFile(PChar(FileName), FindData);<br> if Handle <> INVALID_HANDLE_VALUE then<br> begin<br> Windows.FindClose(Handle);<br> if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then<br> begin<br> case FileTimeType of<br> fttCreation:<br> FileTimeToLocalFileTime(FindData.ftCreationTime, LocalFileTime);<br> fttLastAccess:<br> FileTimeToLocalFileTime(FindData.ftLastAccessTime, LocalFileTime);<br> fttLastWrite:<br> FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);<br> end;<br> if FileTimeToDosDateTime(LocalFileTime, LongRec(DosDateTime).Hi,<br> LongRec(DosDateTime).Lo) then <br> begin<br> Result := FileDateToDateTime(DosDateTime);<br> Exit;<br> end;<br> end;<br> end;<br> Result := -1;<br>end;<br><br>使用举例,获取文件最后修改时间:<br>ShowMessage(DateTimeToStr(GetFileDateTime('c:/key.txt',fttLastWrite)));