如何得到exe本身的修改日期?

云帆 2006-01-04 11:41:29
程序运行的时候,我想把它的修改日期显示出来,怎么得到?
...全文
185 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hellolongbin 2006-01-05
  • 打赏
  • 举报
回复
这个函数应该是你想要的

function TForm1.FGetFileTime(sFileName: string;
TimeType: Integer): TDateTime;
var
ffd:TWin32FindData;
dft:DWord;
lft,Time:TFileTime;
H:THandle;
begin
H:=Windows.FindFirstFile(PChar(sFileName),ffd);
case TimeType of
0: Time:=ffd.ftCreationTime;
1: Time:=ffd.ftLastWriteTime;
2: Time:=ffd.ftLastAccessTime;
end;

//获取文件信息
if (H <> INVALID_HANDLE_VALUE) then
begin
Windows.FindClose(H);
FileTimeToLocalFileTime(Time,lft);
//转换FILETIME格式成为DOStime格式
FileTimeToDosDateTime(lft,LongRec(dft).Hi,LongRec(dft).Lo);
//转换DOStime格式成为Delphi's应用的TdateTime格式
Result:=FileDateToDateTime(dft);
end
else
result:=0;
end;
老之 2006-01-04
  • 打赏
  • 举报
回复
ShowMessage(DateToStr(FileDateToDateTime(FileAge(Application.ExeName))));

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧