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用twebbrowser组件在Delphi中post数据和取得网页源文件

Delphi一个简单的多线程例子

windows关机函数exitwindowsex使用大全(适用windows所有操作平台)

Delphi 如何让 tgpimage 直接从流中加载图片?

Delphi txt编码互转 ansi utf-8

Delphi image 等比例缩小

Delphi adotable1 链接mdb数据库

Delphi源码简单的实现粘贴复制代码

Delphi xe中将正则表达式tregex的使用

Delphi字符串旋转任意角度

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



打赏

取消

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

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

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

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

评论

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