Delphi 获取文件创建时间,修改时间,最后


本文整理自网络,侵删。

 
function GetFileLastAccessTime(FileName: string; AFlag: Integer): TDateTime;
var
  WFD: TWin32FindData;
  FileTime: TFileTime;
  hFile: THandle;
  DFT: DWORD;
begin
  hFile := FindFirstFile(Pchar(FileName), WFD);
  if hFile <> INVALID_HANDLE_VALUE then
  begin
    // FindClose(hFile);
    case AFlag of
      1:
        FileTimeToLocalFileTime(WFD.ftCreationTime, FileTime);   //创建时间
      2:
        FileTimeToLocalFileTime(WFD.ftLastAccessTime, FileTime);  //上一次访问时间
      3:
        FileTimeToLocalFileTime(WFD.ftLastWriteTime, FileTime); //最后写入时间
    end;
    FileTimeToDosDateTime(FileTime, LongRec(DFT).HI, LongRec(DFT).LO);
    Result := FileDateToDateTime(DFT);
  end;
end;

相关阅读 >>

Delphi 播放声音 建议采用 异步方式,比较流畅

Delphi 查看内存数据的函数

Delphi 屏幕渐变效果的源代码

Delphi directx简单应用

Delphi 安卓app自动升级

Delphi 之 tmemo组件使用

Delphi监控文件夹

Delphi xe android将域名转化为ip

Delphi 自带大小写转换

Delphi xe2和xe3开发的程序中加入管理员权限申请

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



打赏

取消

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

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

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

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

评论

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