如何获取文件的更新时间

ran 2000-06-23 02:34:00
请问我如何才能获取某个文件(文本文件)的更新时间. 
...全文
266 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
skt642 2001-05-31
  • 打赏
  • 举报
回复
62852关注!
shylsz 2000-06-23
  • 打赏
  • 举报
回复
The GetFileTime function retrieves the date and time that a file was created, last accessed, and last modified.

BOOL GetFileTime(

HANDLE hFile, // identifies the file
LPFILETIME lpCreationTime, // address of creation time
LPFILETIME lpLastAccessTime, // address of last access time
LPFILETIME lpLastWriteTime // address of last write time
);
Limu 2000-06-23
  • 打赏
  • 举报
回复
Use the GetFileTime API function.The C protype like this:
BOOL GetFileTime(
HANDLE hFile, // identifies the file
LPFILETIME lpCreationTime, // address of creation time
LPFILETIME lpLastAccessTime, // address of last access time
LPFILETIME lpLastWriteTime // address of last write time
);
The lpLastWriteTime variable include the value that you want.
Limu 2000-06-23
  • 打赏
  • 举报
回复
Use the GetFileTime API function.The C protype like this:
BOOL GetFileTime(
HANDLE hFile, // identifies the file
LPFILETIME lpCreationTime, // address of creation time
LPFILETIME lpLastAccessTime, // address of last access time
LPFILETIME lpLastWriteTime // address of last write time
);
The lpLastWriteTime variable include the value that you want.
华南虎哥 2000-06-23
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
iFileHandle : Integer;
UpdateTime:TDateTime;
begin
if OpenDialog1.Execute then
begin
iFileHandle := FileOpen(OpenDialog1.FileName, fmOpenRead);
UpDateTime:=FileDateToDateTime(FileGetDate(iFileHandle));
FileClose(iFileHandle);
end;
label1.caption:=datetimetostr(Updatetime);
end;
LaoZheng 2000-06-23
  • 打赏
  • 举报
回复
var
FileHandle : Integer;
DateTime:TDateTime
begin
FileHandle := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);
DateTime:=FileDateToDateTime(FileGetDate(FileHandle));
Fileclose(FileHandle);
end;

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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