本文整理自网络,侵删。
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 xe6 使用intent启动活动并在android应用程序中获取返回值的示例
更多相关阅读请进入《Delphi》频道 >>