procedure TForm1.Button1Click(Sender: TObject); var ss:Tsearchrec; filepath:string; fileTime:integer; fileName:string; begin filepath:='c:\'; if findfirst(filepath+'*.*',faAnyFile,ss)=0 then begin if not ((ss.Attr and fadirectory)=fadirectory) then begin fileTime:=ss.Time; fileName:=ss.Name; end; while findnext(ss)=0 do begin if not ((ss.attr and fadirectory)=fadirectory) then begin if ss.Time<fileTime then begin fileTime:=ss.Time; fileName:=ss.Name; end; end; end; findclose(ss); showmessage(filename); end; end;
var ss:Tsearchrec;
filepath:string;
fileTime:integer;
fileName:string;
begin
filepath:='c:\';
if findfirst(filepath+'*.*',faAnyFile,ss)=0 then
begin
if not ((ss.Attr and fadirectory)=fadirectory) then
begin
fileTime:=ss.Time;
fileName:=ss.Name;
end;
while findnext(ss)=0 do
begin
if not ((ss.attr and fadirectory)=fadirectory) then
begin
if ss.Time<fileTime then
begin
fileTime:=ss.Time;
fileName:=ss.Name;
end;
end;
end;
findclose(ss);
showmessage(filename);
end;
end;
把这句家在开头就可以了
fileTime:=2147483647;