此内容摘自zuobaoquan的技术共享贴~ http://topic.csdn.net/u/20090426/17/895a522b-3ca9-4b7b-baac-2f1b6f5c561a.html //原理为向whatismyip发送一次GET请求,whatismyip网站返回IP内容! //也可以自己做一个aspx页面,其内用Request.UserHostAddress来获取远端连接的IP地址 uses ComObj; function _GetPublicIPAddress: string; const DefaultPublicIPAddressUrl: string = 'http://www.whatismyip.com/automation/n09230945.asp'; var xmlHttp: OleVariant; begin xmlHttp:= CreateOleObject('Microsoft.XMLHTTP'); try xmlHttp.Open('GET', DefaultPublicIPAddressUrl, False); xmlHttp.Send; if xmlHttp.status='200' then begin Result:=xmlHttp.responseText; end; except Result:='0.0.0.0'; end; end;