直接用API来写就可以了.<br>下面是某程序的部分片段,看懂后相信你的问题就OK了.<br>--------------------------------------------------<br>program XXXX;<br><br>uses<br> windows,messages,winsock,sysutils;<br><br>{$R *.RES}<br><br>const<br> CRLF=#13#10;<br>var<br> thd:array[1..1000] of integer;<br> tid:array[1..1000] of dword;<br> faint,hMutex,mcount,speed,newtime,oldtime,num,count,err:integer;<br> s1:string;<br> sbuf:array[0..1024] of char;<br> dest:string;<br> allstart:boolean;<br>//以下是网络连接的过程<br>function StartNet(host:string;port:integer):integer;<br>var<br> wsadata:twsadata;<br> fsocket:integer;<br> SockAddrIn:TSockAddrIn;<br> mct,err:integer;<br>begin<br> //为网络连接作好准备(用winsock1.1以上版本)<br> err:=WSAStartup($0101,WSAData);<br> //创建一个客户端套接字(Client Socket,用SOCK_STREAM,即TCP协义)<br> FSocket := socket(PF_INET, SOCK_STREAM,IPPROTO_IP);<br> //初始化网络数据<br> SockAddrIn.sin_addr.s_addr:=inet_addr(PChar(host));<br> SockAddrIn.sin_family := PF_INET;<br> SockAddrIn.sin_port :=htons(port);<br> //客户端向smtp进行连接<br> mct:=0;<br> repeat<br> err:=connect(FSocket,SockAddrIn, SizeOf(SockAddrIn));<br> inc(mct);<br> if mct>0 then break;<br> until err=0;<br> Result:=FSocket;<br>end;<br>//以下是网络关闭的过程<br>procedure StopNet(Fsocket:integer);<br>var<br> err:integer;<br>begin<br> //发信结束,关闭客户端套接字(Close Client Socket)<br> err:=closesocket(FSocket);<br> //清除网络参数<br> err:=WSACleanup;<br>end;<br><br>function PostData(uid,pid:string):integer;<br>const<br> MaxSize=1024;<br>var<br> FSocket:integer;<br> HeadStr,PostStr:string;<br> DataBuf:array[0..MaxSize*60] of char;<br> TmpBuf:array[0..MaxSize*16] of char;<br> SubStr:array[0..MaxSize] of char;<br> err,cut:integer;<br>begin<br>// repeat<br> FSocket:=StartNet('202.104.32.236',80);<br> // PostData(FSocket,dest);<br> //--------------------申请第一步-------------------------------------<br> PostStr:=//下面是POST数据部分<br> 'FullName=&NewUserName='+uid+'&DomainName=21cn.com&submit.x=33&submit.y=10';<br> HeadStr:=//下面是HEAD数据部分<br> 'POST /extend/gb/std/NULL/NULL/register.gen HTTP/1.1'+CRLF+<br> 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*'+CRLF+<br> 'Accept-Language: zh-cn'+CRLF+<br> 'Content-Type: application/x-www-form-urlencoded'+CRLF+<br> 'Accept-Encoding: gzip, deflate'+CRLF+<br> 'User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)'+CRLF+<br> 'Host: webmail.21cn.com'+CRLF+ //webmail.21cn.com=202.104.32.236<br> 'Connection: Keep-Alive'+CRLF+<br> 'Referer: http://webmail.21cn.com/extend/gb/UserName.htm'+CRLF+<br> 'Content-Length: '+inttostr(length(PostStr))+CRLF+CRLF;<br> strcopy(DataBuf,pchar(HeadStr+PostStr+CRLF));<br> err:=send(FSocket,DataBuf,strlen(DataBuf),MSG_DONTROUTE);<br> strcopy(DataBuf,pchar(''));<br> repeat<br> err:=recv(FSocket,TmpBuf,MaxSize,0);<br> strcopy(DataBuf,pchar(strpas(DataBuf)+strpas(TmpBuf)));<br> until err<=0;<br> strcopy(SubStr,pchar('已经被占用了'));<br> if AnsiStrPos(DataBuf,SubStr)<>nil then<br> WriteCaption(hEditEMail,pchar('用户已存在'));<br> strcopy(SubStr,pchar('用户名太短'));<br> if AnsiStrPos(DataBuf,SubStr)<>nil then<br> WriteCaption(hEditEMail,pchar('用户名太短'));<br> strcopy(SubStr,pchar('非法字符'));<br> if AnsiStrPos(DataBuf,SubStr)<>nil then<br> WriteCaption(hEditEMail,pchar('非法字符'));<br><br> WriteCaption(handle,pchar(inttostr(strlen(DataBuf))));<br> StopNet(Fsocket);<br>// WriteCaption(hEditCount,pchar(inttostr(strlen(DataBuf))));<br><br>// until err>0;<br> //------------------------------<br> FSocket:=StartNet('202.104.32.236',80);<br> //--------------------申请第二步-------------------------------------<br> PostStr:=//下面是POST数据部分<br> 'Agree=Agree&DomainName=21cn.com&NewUserName='+uid+'&Version=2&'+<br> 'LastName=xxx&CommonName=xxx&Password='+pid+'&ConfirmPassword='+pid+'&PasswordReminderQuestion=xxx&PasswordReminderAnswer=xxx'+<br> '&PersonalID=&Gender=0&birth_year=1999&birth_month=1&birth_day=1&MailBox=&PasswordReminderAnswer3=&Country=Null&Province=Null&City=';<br> HeadStr:=//下面是HEAD数据部分<br> 'POST /extend/gb/std/NULL/NULL/AddUser1.gen HTTP/1.1'+CRLF+<br> 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*'+CRLF+<br> 'Accept-Language: zh-cn'+CRLF+<br> 'Content-Type: application/x-www-form-urlencoded'+CRLF+<br> 'Accept-Encoding: gzip, deflate'+CRLF+<br> 'User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)'+CRLF+<br> 'Host: webmail.21cn.com'+CRLF+ //webmail.21cn.com=202.104.32.236<br> 'Connection: Keep-Alive'+CRLF+<br> 'Referer: http://webmail.21cn.com/extend/gb/std/NULL/NULL/register.gen?FullName=&NewUserName='+uid+'&DomainName=21cn.com&submit.x=33&submit.y=10'+CRLF+<br> 'Content-Length: '+inttostr(length(PostStr))+CRLF+CRLF;<br> strcopy(DataBuf,pchar(HeadStr+PostStr+CRLF));<br> err:=send(FSocket,DataBuf,strlen(DataBuf),MSG_DONTROUTE);<br> strcopy(DataBuf,pchar(''));<br> repeat<br> err:=recv(FSocket,TmpBuf,MaxSize,0);<br> strcopy(DataBuf,pchar(strpas(DataBuf)+strpas(TmpBuf)));<br> until err<=0;<br> strcopy(SubStr,pchar('你已经成功'));<br> if AnsiStrPos(DataBuf,SubStr)<>nil then WriteCaption(hEditEMail,pchar('申请成功!'));<br> //WriteCaption(hEditCount,pchar(inttostr(strlen(DataBuf))));<br> StopNet(Fsocket);<br>end;<br><br>//------------------------------------<br>//以下是线程创建时调用的线程函数<br>function fun(Parameter: Pointer): Integer; stdcall;<br>var<br> uid,pid:string;<br>begin<br> ReadCaption(hEditEmail,sbuf);uid:=strpas(sbuf);<br> ReadCaption(hEditCount,sbuf);pid:=strpas(sbuf);<br> PostData(uid,pid);<br> result:=0;<br>end;<br><br><br>