function TForm1.ListDir(Path: string; List: TStringList): Integer; //非递归遍历文件夹
var
filename:string;
j:integer;
i:boolean;
filedata:Twin32finDdata;
fhandle:Thandle;
begin
// 此函数返回本目录下的文件夹和文件。
j:=0;
if path[length(path)]<>'\' then
path:=path+'\';//保证patch的格式为?:\???\??\的形式
try
fhandle:=findfirstfile(pchar(path+'*.*'),filedata);
if (fhandle=INVALID_HANDLE_VALUE) then //INVALID_HANDLE_VALUE api自定义常量
begin
windows.findclose(fhandle);
result:=0;
end;
list.Add(path+strpas(filedata.cFileName));
i:=findnextfile(fhandle,filedata);
while I do
begin
inc(j);
list.Add(path+strpas(filedata.cFileName));
i:=findnextfile(fhandle,filedata);
end;
result:=j;
windows.findclose(fhandle);
except
result:=0;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Files.Count=0 then Exit;
if Timer1.Tag>Files.Count then Timer1.Tag:=0;
Image1.Picture.Bitmap.LoadFromFile(Files[Timer1.Tag]);
Timer1.Tag:=Timer1.Tag+1;
end;
for i:=0 to youlist.count-1 do
begin
if not image1.picture.bitmap.empty then
begin
image1.Picture.Bitmap.FreeImage; //清除内存
image1.picture.bitmap.loadfromfile(youlist.string[i]);//显示下一个
end;