Program Demo;
var dir:tstringlist;
procedure findname(r:string);
var sr: TSearchRec;
begin
if FindFirst(r+'/*.*', $3f, sr) = 0 then
dir.Items.Add(r+'/'+sr.name);
while FindNext(sr) = 0 do
dir.Items.Add(r+'/'+sr.name);
FindClose(sr);
end;
begin
dir:=tstringlist.create;
findname('c:/windows'); //自己设定目录,把所有文件名存入 dir 中
dir.free;
end.