Delphi 上次访问该文件的时间


本文整理自网络,侵删。

 
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);
begin
MessageDlg(
    'c:\config.sys was last accessed on '
    + DateTimeToStr(GetFileLastAccessTime('c:\vcredist_x86.log')),
    mtInformation, [mbOk], 0
);
end;

相关阅读 >>

Delphi mscomm简单的中间pc串口数据中转

选择 Delphi 的 9 条理由

Delphi 10.3 控件遮挡 webbrowser

删除Delphi组件tstringlist中的重复项目

Delphi 个人所得税计算函数

Delphi 比较版本号

Delphi执行sql提示“不正常地定义参数对象”,“提供了不一致或不完整的信息”错误

Delphi 屏幕截屏

Delphixe firemonkey 如何画图

Delphi tpath

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...