本文整理自网络,侵删。
function GetFileLastAccessTime(sFileName: string): TDateTime;var ffd : TWin32FindData; dft : DWord; lft : TFileTime; h : THandle;begin // get file information h := Winapi.Windows.FindFirstFile(PChar(sFileName), ffd); if INVALID_HANDLE_VALUE <> h then begin Winapi.Windows.FindClose(h);
// convert the FILETIME to local FILETIME FileTimeToLocalFileTime(ffd.ftLastAccessTime, lft);
FileTimeToDosDateTime(lft, LongRec(dft).Hi, LongRec(dft).Lo);
Result := FileDateToDateTime(dft); end;end;
procedure TForm1.FormCreate(Sender: TObject);beginMessageDlg( 'c:\config.sys was last accessed on ' + DateTimeToStr(GetFileLastAccessTime('c:\vcredist_x86.log')), mtInformation, [mbOk], 0);end;
相关阅读 >>
Delphi执行sql提示“不正常地定义参数对象”,“提供了不一致或不完整的信息”错误
更多相关阅读请进入《Delphi》频道 >>