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获取一个窗口的所有子窗口(包括嵌套)

Delphi 删除指定字符串的所有实例

Delphi android 关闭应用程序对话框询问

Delphi 限制form窗体为固定的大小

Delphi 高速替换大文本字符串内容

Delphi 关闭指定窗口

Delphi 判断字符串是否为纯数字组合

Delphi idhttp post 支持 gzip 解压缩

Delphi的cpu调试窗口

Delphi 反转内存的函数

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



打赏

取消

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

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

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

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

评论

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