发信人: redfox (Z掉了几乎所有的版...), 信区: BorlandDev
标  题: Delphi编程 -- 3.1 获得最后使用文件的日期
发信站: 哈工大紫丁香 (2000年09月01日13:48:18 星期五), 站内信件

获得最后使用文件的日期。 
  在Win95中有一项新的功能,就是可以获得访问文件的最后日期。著名的
CleanSweapforWin95软件中就是靠这一功能来作为判断某个文件是否被经常访问的
依据之一。在Delphi中,我们可以通过下面的程序来达到此功能。
  functionGetFileLastAccessTime(sFileName:string):TDateTime;
  var
  ffd:TWin32FindData;
  dft:DWord;
  lft:TFileTime;
  h:THandle;
  begin
  //getfileinformation
  h:ΚWindows.FindFirstFile(PChar(sFileName),ffd);
  if(INVALID—HANDLE—VALUEΙΛh)then
  begin
  //we′relookingforjustonefile,socloseour″find″
  Windows.FindClose(h);
  //converttheFILETIMEtolocalFILETIME
  FileTimeToLocalFileTime(ffd.ftLastAccessTime,lft);
  //convertFILETIMEtoDOStime
  FileTimeToDosDateTime(lft,LongRec(dft).Hi,LongRec(dft).Lo)

  //finally,convertDOStimetoTDateTimeforuseinDelphi′snativedate/
timefunctions
  Result:ΚFileDateToDateTime(dft);
  end;
  end;
  GetFileLastAccessTime()将会以Delphi的TdateTime格式返回你所指定的文
件的最后访问日期。


 

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.227.107]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.464毫秒