我在线程里面动态生成indy控件,但运行时出错,代码如下,请指教。(50分)

  • 主题发起人 yecloudy
  • 开始时间
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.
 
constructor FtpThread.connect(ShowTextLB,ShowWrongLB:TListBox;ftpip:string);
begin
inherited Create(true);
ftp := TFTPIP.create;[blue]//加上这一句,用完后别忘了释放[/blue]
freeonterminate:=true;
ftpName:=ftpip;
ShowLB:=ShowTextLB;
WrongLB:=ShowWrongLB;
Resume;
end;
 
ftp := TFTPIP.create;[blue]//加上这一句,用完后别忘了释放[/blue]
blue什么意思阿。如何释放blue
 
ftp := Tidftp.create();//()里面要填什么参数?
请问大家可不可以send一个INDY有readtimeout的属性给我。
pb90@21cn.com
 
请注意:
creat后
1。bindinds.add
2。binds.default:=xxx
3。binds.items【0】.port:=yyy
否则肯定出错,除非你直接拖进来
 
ftp := Tidftp.create(nil);
 
FTP都没有创建 当然错了
 
楼主能提供成功后的原始代码么?谢谢
 
顶部