Q
qingniao
Unregistered / Unconfirmed
GUEST, unregistred user!
1、请高手高手我怎么样实现继传的,!!+300
2、怎么样统计下载速度的+50
3、怎么样得到本机IP(包括网内的和拨号)和机器名+100
4、怎么样在listview访问第三列(包括第三列)以后的数据的+50
5、我最头疼的问题:
我使用一个线程连接服务器,然后线程结束,然后启动另一个线程下载。
问题是如果连接失败的话,线程结束,我退出程序没有什么问题,或者我不进行连接,退出时也是没有任何问题,就是一旦我连接上服务器,不管我是否启动另一个线程下载,也不管是否我使用IdFTP1.Disconnect,退出程序时都出现“无效的窗口句柄”的错误,请高手解答,我跟踪的好似后程序都是在一个随机的地方出错,我实在没有办法了,高手救命!!
1、连接线程
unit ftpconnectthreadu;
interface
uses
Classes,newpageu,dialogs,ComCtrls,SysUtils,main,IniFiles;
type
Tftpconnectthread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
public
constructor Create(autoftp:Boolean;const tempftp:myftp);
end;
var
theftp:myftp;
implementation
constructor Tftpconnectthread.Create(autoftp:Boolean;const tempftp:myftp);
begin
inherited Create(autoftp);
theftp:=tempftp;
end;
procedure Tftpconnectthread.Execute;
var
myhostdir:hostdir;
i,j,pathmun:integer;
templist:tlistitem;
sizenum:Longword;
filenum:integer;
tempstr:string;
myInifile:TInifile;
ftpproxyuser,ftpproxypass,ftpproxyaddr,ftpproxyport:string;
begin
freeonterminate:=true;
if mainform.IdFTP1.Connected then
mainform.IdFTP1.Disconnect;
mainform.Memo1.Lines.Add('正在连接服务器...');
mainform.Memo1.Lines.Add('连接中...');
myInifile:=TInifile.Create(ExtractFilePath(Paramstr(0))+'ardorangel.ini');
if myInifile.readBool( '代理服务器', '匿名', false) then
begin
ftpproxyuser:='anonymous';
ftpproxypass:='dsfhdf@yahoo.com'
end
else
begin
ftpproxyuser:=myInifile.readstring( '代理服务器', '用户名', '' );
ftpproxypass:=myInifile.readstring( '代理服务器', '密码', '' );
end;
ftpproxyaddr:=myInifile.readstring( '代理服务器', '主机', '' );
ftpproxyport:=myInifile.readstring( '代理服务器', '端口', '' );
if mainform.sbproxy.Down then
begin
mainform.IdFTP1.ProxySettings.Host:=ftpproxyaddr;
mainform.IdFTP1.ProxySettings.UserName:=ftpproxyuser;
mainform.IdFTP1.ProxySettings.Password:=ftpproxypass;
mainform.IdFTP1.ProxySettings.port:=strtoint(trim(ftpproxyport));
mainform.Memo1.Lines.Add('使用代理服务器连接...');
end
else
begin
mainform.IdFTP1.ProxySettings.Host:='';
mainform.IdFTP1.ProxySettings.UserName:='';
mainform.IdFTP1.ProxySettings.Password:='';
mainform.IdFTP1.ProxySettings.port:=0;
end;
if mainform.sbpassive.Down then
begin
mainform.IdFTP1.Passive:=true;
mainform.Memo1.Lines.Add('使用被动连接...');
end
else
mainform.IdFTP1.Passive:=false;
myhostdir:=mainform.gethostanddir(theftp.ftpaddr);
mainform.IdFTP1.host:=myhostdir.ftphost;
mainform.IdFTP1.Username:=theftp.ftpuser;
mainform.IdFTP1.Password:=theftp.ftppass;
mainform.IdFTP1.Port:=strtoint(theftp.ftpport);
if mainform.mpassivity.Checked then
mainform.IdFTP1.Passive:=true
else
mainform.IdFTP1.Passive:=false;
try
mainform.IdFTP1.Connect(true);
except
begin
mainform.Memo1.lines.add('错误代码:'+inttostr(getlasterror));
mainform.Memo1.lines.add('连接服务器失败!');
mainform.sbconnect.Enabled:=true;
mainform.sbdown.Enabled:=false;
mainform.sbdownall.Enabled:=false;
mainform.sbpause.Enabled:=false;
mainform.mdown.Enabled:=false;
mainform.mdownall.Enabled:=false;
mainform.mpause.Enabled:=false;
mainform.mconnect.Enabled:=true;
exit;
end;
end;
if mainform.IdFTP1.Connected then
begin
sizenum:=0;
filenum:=0;
mainform.Memo1.lines.add('成功连接到服务器!');
if mainform.IdFTP1.CanResume= true then
mainform.Memo1.lines.add('服务器支持断点继传')
else
mainform.Memo1.lines.add('服务器不支持断点继传');
if pos('/',myhostdir.ftpdir)<>0 then
begin
j:=pos('/',myhostdir.ftpdir);
pathmun:=0;
while j<>0do
begin
pathmun:=pathmun+j;
tempstr:=copy(myhostdir.ftpdir,pathmun+1,length(myhostdir.ftpdir));
j:=pos('/',tempstr);
end;
if pathmun=length(myhostdir.ftpdir) then
mainform.IdFTP1.ChangeDir(myhostdir.ftpdir)
else
begin
tempstr:=copy(myhostdir.ftpdir,1,pathmun-1);
try
mainform.IdFTP1.ChangeDir(myhostdir.ftpdir)
except
try
mainform.IdFTP1.ChangeDir(tempstr);
except
mainform.Memo1.Lines.Add('不能连接到文件夹...');
end;
end;
end;
end;
mainform.Memo1.lines.add('正在获取文件列表...');
mainform.Memo2.Clear;
try
mainform.IdFTP1.List(mainform.Memo2.Lines);
if mainform.IdFTP1.DirectoryListing.Count=0 then
begin
mainform.Memo1.Lines.Add('没有发现文件...');
mainform.IdFTP1.Disconnect;
mainform.sbconnect.Enabled:=true;
mainform.sbdown.Enabled:=false;
mainform.sbdownall.Enabled:=false;
mainform.sbpause.Enabled:=false;
mainform.mdown.Enabled:=false;
mainform.mdownall.Enabled:=false;
mainform.mpause.Enabled:=false;
mainform.mconnect.Enabled:=true;
mainform.Memo1.lines.add('断开连接!');
mainform.StatusBar1.Panels.Items[0].Text:='状态:断开';
exit
end
else
begin
for i:=0 to mainform.IdFTP1.DirectoryListing.Count-1do
begin
if (mainform.IdFTP1.DirectoryListing.Items.Size div 1024)=0 then
continue;
templist:=mainform.listview1.Items.Add;
templist.Caption :=mainform.IdFTP1.DirectoryListing.Items.FileName;
templist.SubItems.Add(inttostr(mainform.IdFTP1.DirectoryListing.Items.Size div 1024)+'KB');
sizenum:=sizenum+mainform.IdFTP1.DirectoryListing.Items.Size div 1024;
inc(filenum);
end;
if (sizenum div 1024)>0 then
begin
mainform.Memo1.Lines.Add(format('文件总数:%d 个,共有:%d mb%d kb',[filenum,(sizenum div 1024),sizenum-(sizenum div 1024)*1024]));
end
else
begin
mainform.Memo1.Lines.Add(format('文件总数:%d 个,共有:%d kb',[filenum,sizenum]));
end;
mainform.Memo1.Lines.Add('完成列表!');
mainform.sbdown.Enabled:=true;
mainform.sbdownall.Enabled:=true;
mainform.sbpause.Enabled:=true;
mainform.sbconnect.Enabled:=false;
mainform.mdown.Enabled:=true;
mainform.mdownall.Enabled:=true;
mainform.mpause.Enabled:=true;
mainform.mconnect.Enabled:=false;
end;
except
exit;
end;
end;
mainform.Memo1.Lines.Add('线程结束!');
end;
end.
2、下载线程
unitdo
wnlodethreadu;
interface
uses
Classes,main,SysUtils,Dialogs,Messages,Variants, Graphics, Controls, Forms,
ExtCtrls, StdCtrls;
type
tdownlodethread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
public
procedure myaddtotree2;
constructor Create(autoftp:Boolean;const mytempstr:string);
end;
var
tempstr:string;
implementation
constructor tdownlodethread.Create(autoftp:Boolean;const mytempstr:string);
begin
inherited Create(autoftp);
tempstr:=mytempstr;
end;
procedure tdownlodethread.myaddtotree2;
begin
if mainform.TreeView1.Items.Item[mainform.nowdownpos].Text<>'任务显示' then
if MessageDlg('任务完成,是否将任务移除到完成区?',mtconfirmation ,[mbyes,mbno],0)=mryes then
mainform.deltreenode(mainform.TreeView1.Items.Item[mainform.TreeView1.Tag]);
end;
procedure tdownlodethread.Execute;
var
i,j:integer;
isloaded:boolean;
falenum:integer;
totalnum:integer;
begin
mainform.downloading:=true;
isloaded:=true;
falenum:=0;
freeonterminate:=true;
mainform.Memo1.Lines.add('开始下载文件...');
mainform.Memo3.Lines.add('开始下载文件...');
//mainform.CoolTrayIcon1.CycleIcons:=true;
for i:=mainform.ListBox1.Count-1do
wnto 0do
begin
try
mainform.StatusBar1.Panels.Items[1].Text:='当前下载:'+ mainform.ListBox1.Items.Strings;
if mainform.ListView1.Items.Item.Caption=mainform.ListBox1.Items.Strings then
begin
mainform.ListView1.Items.Item.ImageIndex:=2;//正在下
j:=i;
end
else
for j:=mainform.ListView1.Items.Count-1do
wnto 0do
if mainform.ListView1.Items.Item[j].Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item[j].ImageIndex:=2;
//正在下
mainform.nowdownpos:=j;//正在下载的文件位置
***********[高手说明怎么样实现断点继传!!谢谢]**********************8****
if fileexists(tempstr+mainform.ListBox1.Items.Strings)=false then
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true)
else
if mainform.IdFTP1.CanResume then
try
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 开始尝试继传');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 开始尝试继传');
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true,true);
except
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 继传失败,尝试重新下载');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 继传失败,尝试重新下载');
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true);
end
else
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true,true);
except
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 下载失败');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 下载失败');
isloaded:=false;
if mainform.ListView1.Items.Item.Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item.ImageIndex:=3//错误
else
for j:=mainform.ListView1.Items.Count-1do
wnto 0do
if mainform.ListView1.Items.Item[j].Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item[j].ImageIndex:=3;
//错误
inc(falenum);
continue;
end;
if isloaded=true then
begin
if mainform.ListView1.Items.Item.Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item.ImageIndex:=4 //完成
else
for j:=mainform.ListView1.Items.Count-1do
wnto 0do
if mainform.ListView1.Items.Item[j].Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item[j].ImageIndex:=4;//完成
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 下载完成');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 下载完成');
end;
isloaded:=true;
end;
mainform.Memo1.Lines.add('共成功下载 '+inttostr(mainform.ListBox1.Count-falenum)+' 个文件');
mainform.Memo3.Lines.add('共成功下载 '+inttostr(mainform.ListBox1.Count-falenum)+' 个文件');
if falenum>0 then
begin
mainform.Memo1.Lines.add('共下载失败 '+inttostr(falenum)+' 个文件');
mainform.Memo3.Lines.add('共下载失败 '+inttostr(falenum)+' 个文件');
end;
mainform.usehour:=0;
mainform.useminute:=0;
mainform.usesecond:=0;
mainform.Memo1.Lines.add('当前下载结束');
mainform.Memo1.Lines.add('线程结束');
mainform.Memo3.Lines.add('当前下载结束');
mainform.Memo3.Lines.add('线程结束');
mainform.downloading:=false;
mainform.nowdownpos:=0;
Synchronize(myaddtotree2);
end;
end.
2、怎么样统计下载速度的+50
3、怎么样得到本机IP(包括网内的和拨号)和机器名+100
4、怎么样在listview访问第三列(包括第三列)以后的数据的+50
5、我最头疼的问题:
我使用一个线程连接服务器,然后线程结束,然后启动另一个线程下载。
问题是如果连接失败的话,线程结束,我退出程序没有什么问题,或者我不进行连接,退出时也是没有任何问题,就是一旦我连接上服务器,不管我是否启动另一个线程下载,也不管是否我使用IdFTP1.Disconnect,退出程序时都出现“无效的窗口句柄”的错误,请高手解答,我跟踪的好似后程序都是在一个随机的地方出错,我实在没有办法了,高手救命!!
1、连接线程
unit ftpconnectthreadu;
interface
uses
Classes,newpageu,dialogs,ComCtrls,SysUtils,main,IniFiles;
type
Tftpconnectthread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
public
constructor Create(autoftp:Boolean;const tempftp:myftp);
end;
var
theftp:myftp;
implementation
constructor Tftpconnectthread.Create(autoftp:Boolean;const tempftp:myftp);
begin
inherited Create(autoftp);
theftp:=tempftp;
end;
procedure Tftpconnectthread.Execute;
var
myhostdir:hostdir;
i,j,pathmun:integer;
templist:tlistitem;
sizenum:Longword;
filenum:integer;
tempstr:string;
myInifile:TInifile;
ftpproxyuser,ftpproxypass,ftpproxyaddr,ftpproxyport:string;
begin
freeonterminate:=true;
if mainform.IdFTP1.Connected then
mainform.IdFTP1.Disconnect;
mainform.Memo1.Lines.Add('正在连接服务器...');
mainform.Memo1.Lines.Add('连接中...');
myInifile:=TInifile.Create(ExtractFilePath(Paramstr(0))+'ardorangel.ini');
if myInifile.readBool( '代理服务器', '匿名', false) then
begin
ftpproxyuser:='anonymous';
ftpproxypass:='dsfhdf@yahoo.com'
end
else
begin
ftpproxyuser:=myInifile.readstring( '代理服务器', '用户名', '' );
ftpproxypass:=myInifile.readstring( '代理服务器', '密码', '' );
end;
ftpproxyaddr:=myInifile.readstring( '代理服务器', '主机', '' );
ftpproxyport:=myInifile.readstring( '代理服务器', '端口', '' );
if mainform.sbproxy.Down then
begin
mainform.IdFTP1.ProxySettings.Host:=ftpproxyaddr;
mainform.IdFTP1.ProxySettings.UserName:=ftpproxyuser;
mainform.IdFTP1.ProxySettings.Password:=ftpproxypass;
mainform.IdFTP1.ProxySettings.port:=strtoint(trim(ftpproxyport));
mainform.Memo1.Lines.Add('使用代理服务器连接...');
end
else
begin
mainform.IdFTP1.ProxySettings.Host:='';
mainform.IdFTP1.ProxySettings.UserName:='';
mainform.IdFTP1.ProxySettings.Password:='';
mainform.IdFTP1.ProxySettings.port:=0;
end;
if mainform.sbpassive.Down then
begin
mainform.IdFTP1.Passive:=true;
mainform.Memo1.Lines.Add('使用被动连接...');
end
else
mainform.IdFTP1.Passive:=false;
myhostdir:=mainform.gethostanddir(theftp.ftpaddr);
mainform.IdFTP1.host:=myhostdir.ftphost;
mainform.IdFTP1.Username:=theftp.ftpuser;
mainform.IdFTP1.Password:=theftp.ftppass;
mainform.IdFTP1.Port:=strtoint(theftp.ftpport);
if mainform.mpassivity.Checked then
mainform.IdFTP1.Passive:=true
else
mainform.IdFTP1.Passive:=false;
try
mainform.IdFTP1.Connect(true);
except
begin
mainform.Memo1.lines.add('错误代码:'+inttostr(getlasterror));
mainform.Memo1.lines.add('连接服务器失败!');
mainform.sbconnect.Enabled:=true;
mainform.sbdown.Enabled:=false;
mainform.sbdownall.Enabled:=false;
mainform.sbpause.Enabled:=false;
mainform.mdown.Enabled:=false;
mainform.mdownall.Enabled:=false;
mainform.mpause.Enabled:=false;
mainform.mconnect.Enabled:=true;
exit;
end;
end;
if mainform.IdFTP1.Connected then
begin
sizenum:=0;
filenum:=0;
mainform.Memo1.lines.add('成功连接到服务器!');
if mainform.IdFTP1.CanResume= true then
mainform.Memo1.lines.add('服务器支持断点继传')
else
mainform.Memo1.lines.add('服务器不支持断点继传');
if pos('/',myhostdir.ftpdir)<>0 then
begin
j:=pos('/',myhostdir.ftpdir);
pathmun:=0;
while j<>0do
begin
pathmun:=pathmun+j;
tempstr:=copy(myhostdir.ftpdir,pathmun+1,length(myhostdir.ftpdir));
j:=pos('/',tempstr);
end;
if pathmun=length(myhostdir.ftpdir) then
mainform.IdFTP1.ChangeDir(myhostdir.ftpdir)
else
begin
tempstr:=copy(myhostdir.ftpdir,1,pathmun-1);
try
mainform.IdFTP1.ChangeDir(myhostdir.ftpdir)
except
try
mainform.IdFTP1.ChangeDir(tempstr);
except
mainform.Memo1.Lines.Add('不能连接到文件夹...');
end;
end;
end;
end;
mainform.Memo1.lines.add('正在获取文件列表...');
mainform.Memo2.Clear;
try
mainform.IdFTP1.List(mainform.Memo2.Lines);
if mainform.IdFTP1.DirectoryListing.Count=0 then
begin
mainform.Memo1.Lines.Add('没有发现文件...');
mainform.IdFTP1.Disconnect;
mainform.sbconnect.Enabled:=true;
mainform.sbdown.Enabled:=false;
mainform.sbdownall.Enabled:=false;
mainform.sbpause.Enabled:=false;
mainform.mdown.Enabled:=false;
mainform.mdownall.Enabled:=false;
mainform.mpause.Enabled:=false;
mainform.mconnect.Enabled:=true;
mainform.Memo1.lines.add('断开连接!');
mainform.StatusBar1.Panels.Items[0].Text:='状态:断开';
exit
end
else
begin
for i:=0 to mainform.IdFTP1.DirectoryListing.Count-1do
begin
if (mainform.IdFTP1.DirectoryListing.Items.Size div 1024)=0 then
continue;
templist:=mainform.listview1.Items.Add;
templist.Caption :=mainform.IdFTP1.DirectoryListing.Items.FileName;
templist.SubItems.Add(inttostr(mainform.IdFTP1.DirectoryListing.Items.Size div 1024)+'KB');
sizenum:=sizenum+mainform.IdFTP1.DirectoryListing.Items.Size div 1024;
inc(filenum);
end;
if (sizenum div 1024)>0 then
begin
mainform.Memo1.Lines.Add(format('文件总数:%d 个,共有:%d mb%d kb',[filenum,(sizenum div 1024),sizenum-(sizenum div 1024)*1024]));
end
else
begin
mainform.Memo1.Lines.Add(format('文件总数:%d 个,共有:%d kb',[filenum,sizenum]));
end;
mainform.Memo1.Lines.Add('完成列表!');
mainform.sbdown.Enabled:=true;
mainform.sbdownall.Enabled:=true;
mainform.sbpause.Enabled:=true;
mainform.sbconnect.Enabled:=false;
mainform.mdown.Enabled:=true;
mainform.mdownall.Enabled:=true;
mainform.mpause.Enabled:=true;
mainform.mconnect.Enabled:=false;
end;
except
exit;
end;
end;
mainform.Memo1.Lines.Add('线程结束!');
end;
end.
2、下载线程
unitdo
wnlodethreadu;
interface
uses
Classes,main,SysUtils,Dialogs,Messages,Variants, Graphics, Controls, Forms,
ExtCtrls, StdCtrls;
type
tdownlodethread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
public
procedure myaddtotree2;
constructor Create(autoftp:Boolean;const mytempstr:string);
end;
var
tempstr:string;
implementation
constructor tdownlodethread.Create(autoftp:Boolean;const mytempstr:string);
begin
inherited Create(autoftp);
tempstr:=mytempstr;
end;
procedure tdownlodethread.myaddtotree2;
begin
if mainform.TreeView1.Items.Item[mainform.nowdownpos].Text<>'任务显示' then
if MessageDlg('任务完成,是否将任务移除到完成区?',mtconfirmation ,[mbyes,mbno],0)=mryes then
mainform.deltreenode(mainform.TreeView1.Items.Item[mainform.TreeView1.Tag]);
end;
procedure tdownlodethread.Execute;
var
i,j:integer;
isloaded:boolean;
falenum:integer;
totalnum:integer;
begin
mainform.downloading:=true;
isloaded:=true;
falenum:=0;
freeonterminate:=true;
mainform.Memo1.Lines.add('开始下载文件...');
mainform.Memo3.Lines.add('开始下载文件...');
//mainform.CoolTrayIcon1.CycleIcons:=true;
for i:=mainform.ListBox1.Count-1do
wnto 0do
begin
try
mainform.StatusBar1.Panels.Items[1].Text:='当前下载:'+ mainform.ListBox1.Items.Strings;
if mainform.ListView1.Items.Item.Caption=mainform.ListBox1.Items.Strings then
begin
mainform.ListView1.Items.Item.ImageIndex:=2;//正在下
j:=i;
end
else
for j:=mainform.ListView1.Items.Count-1do
wnto 0do
if mainform.ListView1.Items.Item[j].Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item[j].ImageIndex:=2;
//正在下
mainform.nowdownpos:=j;//正在下载的文件位置
***********[高手说明怎么样实现断点继传!!谢谢]**********************8****
if fileexists(tempstr+mainform.ListBox1.Items.Strings)=false then
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true)
else
if mainform.IdFTP1.CanResume then
try
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 开始尝试继传');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 开始尝试继传');
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true,true);
except
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 继传失败,尝试重新下载');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 继传失败,尝试重新下载');
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true);
end
else
mainform.IdFTP1.Get(mainform.ListBox1.Items.Strings,tempstr+mainform.ListBox1.Items.Strings,true,true);
except
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 下载失败');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 下载失败');
isloaded:=false;
if mainform.ListView1.Items.Item.Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item.ImageIndex:=3//错误
else
for j:=mainform.ListView1.Items.Count-1do
wnto 0do
if mainform.ListView1.Items.Item[j].Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item[j].ImageIndex:=3;
//错误
inc(falenum);
continue;
end;
if isloaded=true then
begin
if mainform.ListView1.Items.Item.Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item.ImageIndex:=4 //完成
else
for j:=mainform.ListView1.Items.Count-1do
wnto 0do
if mainform.ListView1.Items.Item[j].Caption=mainform.ListBox1.Items.Strings then
mainform.ListView1.Items.Item[j].ImageIndex:=4;//完成
mainform.Memo1.Lines.add(mainform.ListBox1.Items.Strings+' 下载完成');
mainform.Memo3.Lines.add(mainform.ListBox1.Items.Strings+' 下载完成');
end;
isloaded:=true;
end;
mainform.Memo1.Lines.add('共成功下载 '+inttostr(mainform.ListBox1.Count-falenum)+' 个文件');
mainform.Memo3.Lines.add('共成功下载 '+inttostr(mainform.ListBox1.Count-falenum)+' 个文件');
if falenum>0 then
begin
mainform.Memo1.Lines.add('共下载失败 '+inttostr(falenum)+' 个文件');
mainform.Memo3.Lines.add('共下载失败 '+inttostr(falenum)+' 个文件');
end;
mainform.usehour:=0;
mainform.useminute:=0;
mainform.usesecond:=0;
mainform.Memo1.Lines.add('当前下载结束');
mainform.Memo1.Lines.add('线程结束');
mainform.Memo3.Lines.add('当前下载结束');
mainform.Memo3.Lines.add('线程结束');
mainform.downloading:=false;
mainform.nowdownpos:=0;
Synchronize(myaddtotree2);
end;
end.