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 combobox1dropdown 生成动态下拉列表

Delphi idhttpserver的使用方法

Delphi字符串深入学习

Delphi让tedit控件的内容居中或右对齐,限制位数,仅允许输入数字

Delphi 使电脑睡眠代码

Delphi窗口界面必学的知识

Delphi 枚举消息钩子的代码

Delphi简单读取网上的文本文件

Delphi 10 seattle的android应用程序中使用参数启动服务

Delphi vista以上系统的进程静音

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



打赏

取消

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

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

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

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

评论

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