Delphi获取公网IP地址函数
2011-07-23 21:40
387 查看
uses IdHTTP; function GetPublicIP: string; var strIP, URL: string; iStart, iEnd: Integer; MyIdHTTP: TIdHTTP; begin Result := ''; MyIdHTTP := TIdHTTP.Create(nil); try try URL := MyIdHTTP.Get('http://www.ip138.com/ip2city.asp'); except end; finally MyIdHTTP.Free; end; if Length(URL) <> 0 then begin iStart := Pos('[', URL); iEnd := Pos(']', URL); if (iStart <> 0) and (iEnd <> 0) then begin strIP := Trim(Copy(URL, iStart + 1, iEnd - iStart - 1)); if strIP <> '' then Result := strIP; end; end; end;
获取公网IP地址函数,需引用IdHTTP。
相关文章推荐
- Delphi获取公网IP地址函数
- delphi技术专题---获取网卡物理地址之内存获取方式函数源码
- Linux下获取公网IP地址的方法
- $_SERVER获取URL地址函数的区别
- Delphi通过解析搜狐网页来获取天气的函数
- 旧书重温:0day2【4】动态获取函数地址
- 【网络应用】批处理获取本机的公网IP地址 .
- delphi获取MAC地址的function()
- 通过符号文件获取函数地址
- DELPHI获取网卡MAC地址
- asp中获取当前页面的地址与参数的函数代码
- Delphi 获取内存及CPU信息的函数
- [转载]Windows系统调用架构分析—也谈KiFastCallEntry函数地址的获取
- 获取成员函数地址及获取函数地址
- 获取windows未导出函数地址标准方法
- 获取公网IP地址
- C++ 获取类成员函数地址方法 浅析
- asp中获取当前页面的地址与参数的函数代码
- 在linux下获取本机MAC地址的函数