Y
yecloudy
Unregistered / Unconfirmed
GUEST, unregistred user!
主程序调用。
FtpThreads:=FtpThread.connect(Listbox3,listbox5,ftpip);
//////////////////////////
unit Tftpthread;
interface
uses
Classes,StdCtrls,dialogs,idftp,SysUtils,Extctrls;
type
FtpThread = class(TThread)
private
{ Private declarations }
protected
FtpName,wrong:string;
timer:TTimer;
ftp:Tidftp;
ShowLB,WrongLB:Tlistbox;
procedure Execute;
override;
procedure ChageDir;
procedure showwrong;
public
constructor connect(ShowTextLB,ShowWrongLB:TListBox;ftpip:string);
// destructor destroy;override;
end;
implementation
constructor FtpThread.connect(ShowTextLB,ShowWrongLB:TListBox;ftpip:string);
begin
inherited Create(true);
freeonterminate:=true;
ftpName:=ftpip;
ShowLB:=ShowTextLB;
WrongLB:=ShowWrongLB;
Resume;
end;
procedure FtpThread.Execute;
begin
ftp.Port :=21;
//运行到这里就报错,access violationa at adrress.........
ftp.user:='anonymous';
ftp.password:='anonymous@21cn.com';
ftp.Host:=FtpName;
try
FTP.Connect;
Synchronize(chagedir);
except
On E:Exceptiondo
begin
wrong:=e.Message ;
Synchronize(showwrong);
end;
end
end;
procedure FtpThread.ChageDir;
begin
begin
ShowLb.Items.Clear;
FTP.ChangeDir('/');
FTP.List(ShowLB.Items);
ShowLB.Items .insert(0,'..');
end;
end;
procedure FtpThread.showwrong;
begin
WrongLB.Items .add(FtpName+' fail,because: ' +wrong);
WrongLB.Update ;
end;
end.
FtpThreads:=FtpThread.connect(Listbox3,listbox5,ftpip);
//////////////////////////
unit Tftpthread;
interface
uses
Classes,StdCtrls,dialogs,idftp,SysUtils,Extctrls;
type
FtpThread = class(TThread)
private
{ Private declarations }
protected
FtpName,wrong:string;
timer:TTimer;
ftp:Tidftp;
ShowLB,WrongLB:Tlistbox;
procedure Execute;
override;
procedure ChageDir;
procedure showwrong;
public
constructor connect(ShowTextLB,ShowWrongLB:TListBox;ftpip:string);
// destructor destroy;override;
end;
implementation
constructor FtpThread.connect(ShowTextLB,ShowWrongLB:TListBox;ftpip:string);
begin
inherited Create(true);
freeonterminate:=true;
ftpName:=ftpip;
ShowLB:=ShowTextLB;
WrongLB:=ShowWrongLB;
Resume;
end;
procedure FtpThread.Execute;
begin
ftp.Port :=21;
//运行到这里就报错,access violationa at adrress.........
ftp.user:='anonymous';
ftp.password:='anonymous@21cn.com';
ftp.Host:=FtpName;
try
FTP.Connect;
Synchronize(chagedir);
except
On E:Exceptiondo
begin
wrong:=e.Message ;
Synchronize(showwrong);
end;
end
end;
procedure FtpThread.ChageDir;
begin
begin
ShowLb.Items.Clear;
FTP.ChangeDir('/');
FTP.List(ShowLB.Items);
ShowLB.Items .insert(0,'..');
end;
end;
procedure FtpThread.showwrong;
begin
WrongLB.Items .add(FtpName+' fail,because: ' +wrong);
WrongLB.Update ;
end;
end.