delphi 获取文件创建时间


本文整理自网络,侵删。

 const
  FILE_CREATE_TIME = 0;  //创建时间
  FILE_MODIFY_TIME = 1;  //修改时间
  FILE_ACCESS_TIME = 3;  //访问时间

function TForm1.GetFileLastAccessTime(a_FileName: string;
  a_Flag: Byte): TDateTime;
var
  ffd: TWin32FindData;
  dft: DWord;
  lft: TFileTime;
  h: THandle;
begin
  h:=FindFirstFile(PChar(a_FileName),ffd);
  if h<>INVALID_HANDLE_VALUE then
  begin
    case a_Flag of
      FILE_CREATE_TIME:FileTimeToLocalFileTime(ffd.ftCreationTime,lft);
      FILE_MODIFY_TIME:FileTimeToLocalFileTime(ffd.ftLastWriteTime,lft);
      FILE_ACCESS_TIME:FileTimeToLocalFileTime(ffd.ftLastAccessTime,lft);
    else
      FileTimeToLocalFileTime(ffd.ftLastAccessTime,lft);
    end;
    FileTimeToDosDateTime(lft,LongRec(dft).Hi,LongRec(dft).Lo);
    Result := FileDateToDateTime(dft);
    Windows.FindClose(h);
  end
  else
  Result:=0;
end;

相关阅读 >>

Delphi length 统计指定字符串的长度(即个数)

Delphi getdrivetypea() 查看驱动器类型

Delphi indy 组件包里的 idhttp 组件使用 get 方法下载文件限速的方法

Delphi filesearch 获取指定文件夹下所有文件包括隐藏文件

Delphi 利用hook api函数openprocess与terminateprocess来防止任务管理器结束进程

Delphi 判断timage是否为空及注意事项

Delphi xe [dcc32 fatal error] f2039 could not create output file 问题的解决

Delphi使用spcomm实现串口通信 基础知识

Delphi 动态数组的释放

Delphi datasnap http用法注意事项

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



打赏

取消

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

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

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

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

评论

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