Delphi 上次访问该文件的时间


本文整理自网络,侵删。

 
function GetFileLastAccessTime(sFileName: string): TDateTime;
var
  ffd : TWin32FindData;
  dft : DWord;
  lft : TFileTime;
  h   : THandle;
begin
  // get file information
  h := Winapi.Windows.FindFirstFile(PChar(sFileName), ffd);
  if INVALID_HANDLE_VALUE <> h then
  begin
    Winapi.Windows.FindClose(h);

    // convert the FILETIME to local FILETIME
    FileTimeToLocalFileTime(ffd.ftLastAccessTime, lft);

    FileTimeToDosDateTime(lft, LongRec(dft).Hi, LongRec(dft).Lo);

    Result := FileDateToDateTime(dft);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
MessageDlg(
    'c:\config.sys was last accessed on '
    + DateTimeToStr(GetFileLastAccessTime('c:\vcredist_x86.log')),
    mtInformation, [mbOk], 0
);
end;

相关阅读 >>

Delphi 枚举类型和integer整型之间的互换

Delphi 用firedac处理sqlite的日期型

Delphixe7关于android 检测屏幕是否处于关闭状态

Delphi编程实现图像的淡入浅出

Delphi中combobox的datavalue值

Delphi 生成不重复数字随机码

Delphi检测android mock位置

Delphi trect的宽和高

Delphi xe7实现获取程序是否已管理员模式运行以及运行的windows用户名

Delphi 锁住listview防止刷新

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



打赏

取消

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

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

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

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

评论

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