代码如下: 怎么改才可以是用线程工作的模式unit Unit3;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, ComCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
IdHTTP1: TIdHTTP;
StatusBar1: TStatusBar;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
num:string;
pwd:string;
str,ni:string;
all,sts:string;
i,t:Integer;
List: TStringList;
stream: TStringStream;
postList:TStrings;
htmltext:string;
begin
button1.Enabled:=false;
statusbar1.Panels.Items[1].Text:='处理中…';
List := TStringList.Create;
List.LoadFromFile('test.txt');
for i := 0 to List.Count - 1 do
begin
all:= List[i];
t:=Pos('-',all);
num:=Copy(all,0,t);
pwd:=Copy(all,t+1,Length(all)-t);
//showmessage(num+'--'+pwd);
str:='cmd.exe /c echo '+num+'---'+pwd+' >> save.txt';
winexec(pchar(str),0); try
with IdHTTP1 do
begin
//showmessage(num+'--'+pwd);
IdHttp1.HandleRedirects := True;
IdHttp1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHttp1.Request.Referer := 'http://localhost/login.asp';
sts:='user_id='+num+'&user_pw='+pwd+'&chk=21';
stream := TStringStream.Create(sts);
try
htmltext:=IdHttp1.Post('http://localhost/login.asp',stream);
memo1.Lines.Add(htmltext);
if pos('ok',htmltext)>0 then
ShowMessage('成功');
if pos('ip',htmltext)>0 then
ShowMessage('ip被封');
finally
stream.Free;
end; end;
finally
end; end;
List.Free;
button1.Enabled:=true;
statusbar1.Panels.Items[1].Text:='已停止…';
statusbar1.Panels.Items[3].Text:='检测完毕..';
end;procedure TForm1.Button2Click(Sender: TObject);
begin
close();
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, ComCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
IdHTTP1: TIdHTTP;
StatusBar1: TStatusBar;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
num:string;
pwd:string;
str,ni:string;
all,sts:string;
i,t:Integer;
List: TStringList;
stream: TStringStream;
postList:TStrings;
htmltext:string;
begin
button1.Enabled:=false;
statusbar1.Panels.Items[1].Text:='处理中…';
List := TStringList.Create;
List.LoadFromFile('test.txt');
for i := 0 to List.Count - 1 do
begin
all:= List[i];
t:=Pos('-',all);
num:=Copy(all,0,t);
pwd:=Copy(all,t+1,Length(all)-t);
//showmessage(num+'--'+pwd);
str:='cmd.exe /c echo '+num+'---'+pwd+' >> save.txt';
winexec(pchar(str),0); try
with IdHTTP1 do
begin
//showmessage(num+'--'+pwd);
IdHttp1.HandleRedirects := True;
IdHttp1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHttp1.Request.Referer := 'http://localhost/login.asp';
sts:='user_id='+num+'&user_pw='+pwd+'&chk=21';
stream := TStringStream.Create(sts);
try
htmltext:=IdHttp1.Post('http://localhost/login.asp',stream);
memo1.Lines.Add(htmltext);
if pos('ok',htmltext)>0 then
ShowMessage('成功');
if pos('ip',htmltext)>0 then
ShowMessage('ip被封');
finally
stream.Free;
end; end;
finally
end; end;
List.Free;
button1.Enabled:=true;
statusbar1.Panels.Items[1].Text:='已停止…';
statusbar1.Panels.Items[3].Text:='检测完毕..';
end;procedure TForm1.Button2Click(Sender: TObject);
begin
close();
end;end.
解决方案 »
- delphi中如何用TFileStream追加存储文件
- ICS 的Demo
- 帮我看看这个有什么问题
- 菜问combobox
- 可不可以通过编程telnet到一个主机,然后执行主机上的一个程序?
- 请速回
- 询问:用的是query关联的数据库,那如何控制dbgrid有的列数据可以修改,有的列不要以修改的问题?
- 帮帮忙啊 下面的语句翻译 成delphi的申明是什么啊 ,具体写在哪里啊,help me 555
- 关于结构体内存的对齐方式,请教高手,救命
- 从数据库中提取数据到treeview 多个疑惑
- 大家谈谈目前安装在DELPHI里有哪些和数据库有关的最常用控件?
- 用socket怎么向指定的端口发送文件,远端服务器不要程序。
private
FHttp : TIDHttp;
FIntext : string;
FList : TStringList;
procedure dostatabar;
procedure domessage;
potected
procedure execute;override;
public
constructor create(AText : string);
end;constructor TXXXX.create(AText : string);
begin
Inherited create(True);
FreeOnTerminate := true;
FinText := AText;
resume;
end;procedure TXXXX.dostatabar;
begin
with formXXX{窗体} do begin
....
end;
end;procedure TXXXX.domessage;
begin
处理显示结果...
end;procedure TXXXX.execute;
begin
FHttp := TIDHttp.create(nil);
FList := TStringList.create;
.... 这里把你Button里代码改改放进来
Synchronize(dostatabar);//处理状态栏
Synchronize(domessage);//处理显示结果,如果线程不是安静模式 直接showmessage
....
end;