本文整理自网络,侵删。
const
FILE_CREATE_TIME = 0; //创建时间
FILE_MODIFY_TIME = 1; //修改时间
FILE_ACCESS_TIME = 3; //访问时间
function TForm1.GetFileLastAccessTime(a_FileName: string;
a_Flag: Byte): TDateTime;
var
ffd: TWin32FindData;
dft: DWord;
lft: TFileTime;
h: THandle;
begin
h:=FindFirstFile(PChar(a_FileName),ffd);
if h<>INVALID_HANDLE_VALUE then
begin
case a_Flag of
FILE_CREATE_TIME:FileTimeToLocalFileTime(ffd.ftCreationTime,lft);
FILE_MODIFY_TIME:FileTimeToLocalFileTime(ffd.ftLastWriteTime,lft);
FILE_ACCESS_TIME:FileTimeToLocalFileTime(ffd.ftLastAccessTime,lft);
else
FileTimeToLocalFileTime(ffd.ftLastAccessTime,lft);
end;
FileTimeToDosDateTime(lft,LongRec(dft).Hi,LongRec(dft).Lo);
Result := FileDateToDateTime(dft);
Windows.FindClose(h);
end
else
Result:=0;
end;
相关阅读 >>
Delphi getdrivetypea() 查看驱动器类型
Delphi indy 组件包里的 idhttp 组件使用 get 方法下载文件限速的方法
Delphi filesearch 获取指定文件夹下所有文件包括隐藏文件
Delphi 利用hook api函数openprocess与terminateprocess来防止任务管理器结束进程
Delphi xe [dcc32 fatal error] f2039 could not create output file 问题的解决
更多相关阅读请进入《Delphi》频道 >>