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 fmx 把内容复制到粘贴板上支持跨平台

Delphi 窗体form的formstyle属性设置为fsstayontop时属性设置不起作用问题探讨。

Delphi android device information

Delphi根据字符分割字串成数组

Delphi中break,exit,abort跳出循环的比较

Delphi xe android]获取屏幕的物理分辨率

Delphi opendialog1 打开多个文件

Delphi xe android/ios 手势介绍

Delphi获得硬盘所有分区

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



打赏

取消

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

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

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

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

评论

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