如何解析域名呀?已知道freemail.china.com如何用编程解析出它是203.192.14.220呀?(在线等)(10分)

  • 主题发起人 主题发起人 cntiny
  • 开始时间 开始时间
C

cntiny

Unregistered / Unconfirmed
GUEST, unregistred user!
WSAStartup($0101,WSAData);<br>FSocket:= socket(PF_INET, SOCK_STREAM,IPPROTO_IP);<br>SockAddrIn.sin_addr.s_addr:=inet_addr(pchar('203.192.14.220'));<br>我现在已知道,freemail.china.com但现在上面要填'203.192.14.220'<br>怎么办呀?
 
GetHostByName:<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; WSAData: TWSAData;<br>&nbsp; HostEnt: PHostEnt;<br>&nbsp; sComputerName, sIP: string;<br>begin<br>&nbsp; sComputername:=edit1.text;<br>&nbsp; WSAStartup(2, WSAData);<br>&nbsp; HostEnt := gethostbyname(PChar(sComputerName)); &nbsp;//sComputerName = 'freemail.china.com'<br>&nbsp; if HostEnt &lt;&gt; nil then<br>&nbsp; begin<br>&nbsp; &nbsp; with HostEnt^ do<br>&nbsp; &nbsp; &nbsp; sIP := Format('%d.%d.%d.%d', [Byte(h_addr^[0]), Byte(h_addr^[1]), Byte(h_addr^[2]), Byte(h_addr^[3])]);<br><br>&nbsp; end;<br>&nbsp; WSACleanup;<br>&nbsp; edit2.text:=sIP;<br>end;<br>
 
或者用ping
 
接受答案了.
 
后退
顶部