在DLL中加个窗体啊,在窗体上放置SOCKET控件不行么?这样就可以不用动态创建了。<br><br>或者<br>type<br> TMyErrorEvent = class(TObject)<br> procedure ClientSocketError(Sender: TObject;<br> Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;<br> var ErrorCode: Integer);<br> end;<br><br>procedure TMyErrorEvent.ClientSocketError(Sender: TObject;<br> Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;<br> var ErrorCode: Integer);<br>begin<br> {...}<br>end;<br><br>procedure CreateClientSocket;<br>var<br> MyErrorEvent: TMyErrorEvent;<br> tmpClientSocket: TClientSocket;<br>begin<br> tmpClientSocket := TClientSocket.Create(nil);<br> tmpClientSocket.OnError := MyErrorEvent.ClientSocketError;<br> {...}<br>end;