//==============================================================================// 白河愁 IndyHttp Thread 控件 http://www.ff18.com 广州游戏小组//// Ver 1.00 2009/03/16 第一个版本//==============================================================================unit IdHTTPThreadUnit;interfaceuses Windows, Classes, IdHTTP;type //定义一个事件,以便接收返回信息 TOnThreadReceive = procedure(ResData: string) of object; TIdHTTPThread = class(TIdHTTP) private FOnThreadReceive: TOnThreadReceive; protected { Protected declarations } public //某种意义上重载原来那2个函数 procedure PostThread(AURL: string; Param: TStringList); procedure GetThread(AURL: string); published property OnThreadReceive: TOnThreadReceive read FOnThreadReceive write FOnThreadReceive; end;{ TIdHTTPThreadCore } TIdHTTPThreadCore = class(TThread) private FIdHTTP: TIdHTTP; FParent: TIdHTTPThread; FURL: string; FParam: TStringList; FRes: string; FPost: Boolean; protected procedure Execute; override; procedure DoEvent; public constructor Create(IdHTTPThread: TIdHTTPThread; URL: string; Param: TStringList = nil ; Post: Boolean = False); destructor Destroy; override; published end;procedure Register;implementationprocedure Register;begin RegisterComponents('Kryso NewWork', [TIdHTTPThread]);end;{ TIdHTTPThread }procedure TIdHTTPThread.GetThread(AURL: string);begin TIdHTTPThreadCore.Create(Self, AURL, nil, false);end;procedure TIdHTTPThread.PostThread(AURL: string; Param: TStringList);begin TIdHTTPThreadCore.Create(Self, AURL, Param, True);end;{ TIdHTTPThreadCore }constructor TIdHTTPThreadCore.Create(IdHTTPThread: TIdHTTPThread; URL: string; Param: TStringList = nil; Post: Boolean = False);begin inherited Create(True); FParent:= IDHTTPThread; FURL:= URL; FPost:= Post; if FPost then begin FParam:= TStringList.Create; FParam.Text:= Param.Text; end; FIdHTTP:= TIdHTTP.Create(nil); FIdHTTP.AuthRetries:= FParent.AuthRetries; FIdHTTP.AllowCookies:= FParent.AllowCookies; FIdHTTP.HandleRedirects:= FParent.HandleRedirects; FIdHTTP.ProtocolVersion:= FParent.ProtocolVersion; FIdHTTP.RedirectMaximum:= FParent.RedirectMaximum; FIdHTTP.ProxyParams:= FParent.ProxyParams; FIdHTTP.Request:= FParent.Request; FIdHTTP.HTTPOptions:= FParent.HTTPOptions; FIdHTTP.Host:= FParent.Host; FIdHTTP.Port:= FParent.Port; FIdHTTP.OnRedirect:= FParent.OnRedirect; FIdHTTP.OnSelectAuthorization:= FParent.OnSelectAuthorization; FIdHTTP.OnSelectProxyAuthorization:= FParent.OnSelectProxyAuthorization; FIdHTTP.OnAuthorization:= FParent.OnAuthorization; FIdHTTP.OnProxyAuthorization:= FParent.OnProxyAuthorization; FIdHTTP.OnConnected:= FParent.OnConnected; FIdHTTP.OnDisconnected:= FParent.OnDisconnected; FIdHTTP.OnWork:= FParent.OnWork; FIdHTTP.OnWorkBegin:= FParent.OnWorkBegin; FIdHTTP.OnWorkEnd:= FParent.OnWorkEnd; FIdHTTP.OnStatus:= FParent.OnStatus; Self.FreeOnTerminate:= True; Self.Resume;end;destructor TIdHTTPThreadCore.Destroy;begin FIdHTTP.Free; if FPost then FParam.Free; inherited;end;procedure TIdHTTPThreadCore.Execute;begin inherited; while not Self.Terminated do begin FRes:= ''; if FPost then FRes:= FIdHTTP.Post(FURL, FParam) else FRes:= FIdHTTP.Get(FURL); if FRes <> '' then begin Synchronize(DoEvent); Self.Terminate; Self.WaitFor; end; end;end;procedure TIdHTTPThreadCore.DoEvent;begin if Assigned(FParent.OnThreadReceive) then FParent.OnThreadReceive(FRes);end;end.这是什么代码? 没看出厉害在哪.平常在论坛貌似很厉害的白河愁, 难道真的要写东西水平就这样? 理论和实战距离太大. 笑死啦, 哈哈哈.