Delphi 得到文件创建时间,修改时间,访问时间


本文整理自网络,侵删。

 procedure TForm1.Button1Click(Sender: TObject);
var
  FileOp : TOFStruct ;
  FHandle : THandle ;
  FInfo : TByHandleFileInformation ;
  dtCreate : TSystemTime;
  Temp:_FileTime;
begin
  memo1.clear;

  setlasterror(20);
  FHandle:= openfile(pchar(edit1.text),FileOp ,OF_READ);
  GetFileInformationByHandle(FHandle,FInfo);

  memo1.Lines.Add('File Attributes : '+inttostr(FInfo.dwFileAttributes));


  FileTimeToLocalFileTime(FInfo.ftCreationTime,Temp);
  FileTimeToSystemTime(Temp,dtCreate);

  memo1.Lines.Add('File Create Time : '
  +inttostr(dtCreate.wYear)+'-'
  +inttostr(dtCreate.wMonth)+'-'
  +inttostr(dtCreate.wDay)+' '
  +inttostr(dtCreate.wHour)+':'
  +inttostr(dtCreate.wMinute)+':'
  +inttostr(dtCreate.wSecond) );

  FileTimeToLocalFileTime(FInfo.ftLastAccessTime,Temp);
  FileTimeToSystemTime(Temp,dtCreate);

  memo1.Lines.Add('File Last Access Time : '
  +inttostr(dtCreate.wYear)+'-'
  +inttostr(dtCreate.wMonth)+'-'
  +inttostr(dtCreate.wDay)+' '
  +inttostr(dtCreate.wHour)+':'
  +inttostr(dtCreate.wMinute)+':'
  +inttostr(dtCreate.wSecond) );

  FileTimeToLocalFileTime(FInfo.ftLastWriteTime,Temp);
  FileTimeToSystemTime(Temp,dtCreate);

  memo1.Lines.Add('File Last Write Time : '
  +inttostr(dtCreate.wYear)+'-'
  +inttostr(dtCreate.wMonth)+'-'
  +inttostr(dtCreate.wDay)+' '
  +inttostr(dtCreate.wHour)+':'
  +inttostr(dtCreate.wMinute)+':'
  +inttostr(dtCreate.wSecond) );

  memo1.Lines.Add('File Path and Name : '+FileOp.szPathName);

  _lclose(FHandle);

end;

相关阅读 >>

Delphi 隐藏进程的单元 unit hideprocess.pas

Delphi 建立access数据库

Delphi如何简单取得后缀名

Delphi窗口显示于parent控件上

Delphi twebbrowser:确定带有框架的页面何时完成

Delphi android 保持唤醒状态

Delphi 闪盘小偷

Delphi 获取系统托盘程序列表

xp/2003下Delphi最简单的方法开放3389

Delphi读取文本文件的最后一行

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



打赏

取消

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

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

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

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

评论

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