function GetFileTimeInfor(FileName:string;TimeFlag:integer):string;<br> {<br> 得到文件的时间信息<br> TimeFlag:= 1 返回文件创建时间<br> := 2 返回文件修改时间<br> := 3 返回上次访问文件的时间<br> }<br>var<br> LocalFileTime : TFileTime;<br> fhandle:integer;<br> DosFileTime : DWORD;<br> FindData : TWin32FindData;<br>begin<br> fhandle := FindFirstFile(Pchar(FileName), FindData);<br> if (FHandle <> INVALID_HANDLE_VALUE) then<br> begin<br> if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then<br> begin<br> case TimeFlag of<br> 1:<br> begin<br> FileTimeToLocalFileTime(FindData.ftCreationTime , LocalFileTime);<br> FileTimeToDosDateTime(LocalFileTime, LongRec(DosFileTime).Hi,LongRec(DosFileTime).Lo);<br> result :=DateTimeToStr(FileDateToDateTime(DosFileTime));<br> end;<br> 3:<br> begin<br> FileTimeToLocalFileTime(FindData.ftLastAccessTime , LocalFileTime);<br> FileTimeToDosDateTime(LocalFileTime, LongRec(DosFileTime).Hi,LongRec(DosFileTime).Lo);<br> result :=DateTimeToStr(FileDateToDateTime(DosFileTime));<br> end;<br> 2:<br> begin<br> FileTimeToLocalFileTime(FindData.ftLastWriteTime , LocalFileTime);<br> FileTimeToDosDateTime(LocalFileTime, LongRec(DosFileTime).Hi,LongRec(DosFileTime).Lo);<br> result :=DateTimeToStr(FileDateToDateTime(DosFileTime));<br> end;<br> end; //case;<br> end;<br> end;<br>end;