HanDs
管理员

[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;


学习中请遵守法律法规,本网站内容均来自于互联网,本网站不负担法律责任
得到 文件 创建 时间
#1楼
发帖时间:2016-7-9   |   查看数:0   |   回复数:0
游客组
快速回复