Y
ychy
Unregistered / Unconfirmed
GUEST, unregistred user!
请问为什么下面线程的excute并没有执行?
SgFilter:=TSgFilter.create (mainform.Handle,listbox10);
能够进入到线程里面,但却调用不了excute。
unit TSingleFilterThread;
interface
uses
Classes ,StrUtils,Dialogs,Extctrls,Windows,Messages,Winsock,stdctrls,Gauges,Sysutils,
IdFTP,IdComponent,FtpCli, Psock, IdTCPConnection, IdTCPClient , IdBaseComponent,IdIntercept;
const
MAXCOUNT=300;
WM_FilterConnectSuccess=wm_user+25;
wm_FilterTryConnect=wm_user+26;
WM_Filterallok=wm_user+27;
WM_FilterConnectFail=wm_user+28;
type
TSingleFilter = class(TThread)
private
{ Private declarations }
protected
wparent:HWND;
ftp:Tidftp;
mylistbox:TListbox;
procedure Execute;
override;
public
constructor create(sparent:HWND;Listbox:Tlistbox);
end;
var
TFilterFile:TextFile;
implementation
uses unit1;
constructor TSingleFilter.create (sparent:HWND;listbox:Tlistbox);
begin
inherited Create(true);
Freeonterminate:=true;
mylistbox:=listbox;
wparent:=sparent;
resume;
end;
procedure TSingleFilter.Execute ;
var
wrongnumber,i:integer;
ftpip,wrong:ANsiString;
begin
Ftp:=Tidftp.Create(nil);
AssignFile(TFilterFile,'FilterFile.txt');
Rewrite(TFilterFile);
ftp.User :='anonymous' ;
ftp.Password :='anonymous@21cn.com';
ftp.Port :=21;
for i:=0 to mylistbox.Count - 1do
begin
if ftp.Connected then
ftp.Disconnect ;
ftpip:=mylistbox.Items;
ftp.Host :=ftpip;
try
begin
sendmessage(wparent,wm_FiltertryConnect,integer(pchar(ftpip)),0);
FTP.Connect;
sendmessage(wparent,wm_FilterConnectSuccess,integer(pchar(ftpip)),0);
writeLn(TFilterFile,'1',',',ftpip,',','1',',','0');
end;
except
On E:Exceptiondo
begin
wrong:=e.Message ;
sendmessage(wparent,wm_FilterConnectFail,integer(pchar(ftpip+' 连接失败,因为: ' +wrong)),0);
try
wrongNumber:=strtoint(copy(wrong,1,3));
except
wrongnumber:=1;
end;
WriteLn(TFilterFile,'1',',',ftpip,',','0',',',wrongnumber);
end;
end;
end;
ftp.Free ;
closeFile(TFilterFile);
sendmessage(wparent,wm_Filterallok,0,0);
end;
end.
SgFilter:=TSgFilter.create (mainform.Handle,listbox10);
能够进入到线程里面,但却调用不了excute。
unit TSingleFilterThread;
interface
uses
Classes ,StrUtils,Dialogs,Extctrls,Windows,Messages,Winsock,stdctrls,Gauges,Sysutils,
IdFTP,IdComponent,FtpCli, Psock, IdTCPConnection, IdTCPClient , IdBaseComponent,IdIntercept;
const
MAXCOUNT=300;
WM_FilterConnectSuccess=wm_user+25;
wm_FilterTryConnect=wm_user+26;
WM_Filterallok=wm_user+27;
WM_FilterConnectFail=wm_user+28;
type
TSingleFilter = class(TThread)
private
{ Private declarations }
protected
wparent:HWND;
ftp:Tidftp;
mylistbox:TListbox;
procedure Execute;
override;
public
constructor create(sparent:HWND;Listbox:Tlistbox);
end;
var
TFilterFile:TextFile;
implementation
uses unit1;
constructor TSingleFilter.create (sparent:HWND;listbox:Tlistbox);
begin
inherited Create(true);
Freeonterminate:=true;
mylistbox:=listbox;
wparent:=sparent;
resume;
end;
procedure TSingleFilter.Execute ;
var
wrongnumber,i:integer;
ftpip,wrong:ANsiString;
begin
Ftp:=Tidftp.Create(nil);
AssignFile(TFilterFile,'FilterFile.txt');
Rewrite(TFilterFile);
ftp.User :='anonymous' ;
ftp.Password :='anonymous@21cn.com';
ftp.Port :=21;
for i:=0 to mylistbox.Count - 1do
begin
if ftp.Connected then
ftp.Disconnect ;
ftpip:=mylistbox.Items;
ftp.Host :=ftpip;
try
begin
sendmessage(wparent,wm_FiltertryConnect,integer(pchar(ftpip)),0);
FTP.Connect;
sendmessage(wparent,wm_FilterConnectSuccess,integer(pchar(ftpip)),0);
writeLn(TFilterFile,'1',',',ftpip,',','1',',','0');
end;
except
On E:Exceptiondo
begin
wrong:=e.Message ;
sendmessage(wparent,wm_FilterConnectFail,integer(pchar(ftpip+' 连接失败,因为: ' +wrong)),0);
try
wrongNumber:=strtoint(copy(wrong,1,3));
except
wrongnumber:=1;
end;
WriteLn(TFilterFile,'1',',',ftpip,',','0',',',wrongnumber);
end;
end;
end;
ftp.Free ;
closeFile(TFilterFile);
sendmessage(wparent,wm_Filterallok,0,0);
end;
end.