多线程问题 高手请进!!!!

lcddda 2010-08-09 10:40:46
unit Unit2;

interface
uses
Classes,unit1;
type
lthread = class(TThread)
protected
procedure execute; override;
end;

implementation
procedure lthread.execute;
var
name:String;
password:string;

GetURL :String;
PostURL :String;
GetHtml :String;
sParams :String;
aParams :TStrings;
aStream :TStringStream;
begin

IdHTTP1 := TIdHTTP.Create(nil); //编译时这条代码提示出错 怎么修改 谢谢!
aParams := TStringList.Create;
aStream := TStringStream.Create('');
form1.memo1.Lines.Clear ;
name:=form1.edit1.Text ;
password:=form1.edit2.Text ;
GetURL := 'http://localhost/getinfo.asp'; {登录页面网址}
PostURL := 'http://localhost/getinfo.asp?password='+password; {提交网址}
sParams := 'name='+name; {提交参数}
try
aParams.Clear;
aParams.Add(sParams);
GetHtml := form1.IdHTTP1.Get(GetURL); {取登录页面}
form1.IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
form1.IdHTTP1.Post(PostURL, aParams, aStream); {提交}
form1.memo1.lines.Add(aStream.DataString);
form1.memo1.SelectAll ;
finally
form1.IdHTTP1.Free;
aParams.Free;
aStream.Free;
end;

end;

end.
...全文
67 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cuit_xiong 2010-08-10
  • 打赏
  • 举报
回复
是不是 在你的form上也就是unit1对应的窗体上放了一个idhttp控件。于是你需要在create了
slmax1 2010-08-10
  • 打赏
  • 举报
回复
IdHTTP1 有声明吗?
oloveuxyz 2010-08-09
  • 打赏
  • 举报
回复
IdHTTP1已经存在form1上,不需要创建的
你这线程里直接操作窗体的VCL 是不行的!
oloveuxyz 2010-08-09
  • 打赏
  • 举报
回复
即使是0分我也会看,但结帖率太低,没有回答问题的心情!
xinghun61 2010-08-09
  • 打赏
  • 举报
回复
将uses Classes,unit1;
改为 uses Classes,unit1,IdHTTP;
lcddda 2010-08-09
  • 打赏
  • 举报
回复
有人帮解决下吗这问题 谢谢了

828

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧