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 tidhttp 超时的解决方案

Delphi随机字符(密码生成)函数

Delphi idhttp下载文件

Delphi 自带gif控件的动画图片加载和播放

Delphi 实现关闭指定进程,自身防杀

Delphi md5单元文件

Delphi xe6 使用intent启动活动并在android应用程序中获取返回值的示例

Delphi 判断网络链接文件是否存在

Delphi windows服务控制单元

Delphi 汉字与区位码

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



打赏

取消

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

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

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

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

评论

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