Delphi获取公网IP地址函数
2011-07-23 21:39
288 查看
1 uses IdHTTP;
2 function GetPublicIP: string;
3 var
4 strIP, URL: string;
5 iStart, iEnd: Integer;
6 MyIdHTTP: TIdHTTP;
7 begin
8 Result := '';
9 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.
2 function GetPublicIP: string;
3 var
4 strIP, URL: string;
5 iStart, iEnd: Integer;
6 MyIdHTTP: TIdHTTP;
7 begin
8 Result := '';
9 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技术专题---获取网卡物理地址之内存获取方式函数源码
- Delphi通过解析搜狐网页来获取天气的函数
- 【网络应用】批处理获取本机的公网IP地址 .
- 通过符号文件获取函数地址
- DELPHI获取网卡MAC地址
- asp中获取当前页面的地址与参数的函数代码
- Delphi 获取内存及CPU信息的函数
- 获取windows未导出函数地址标准方法
- 获取成员函数地址及获取函数地址
- 获取公网IP地址
- asp中获取当前页面的地址与参数的函数代码
- 在linux下获取本机MAC地址的函数
- ioctl函数,可以获取ip地址,修改ip地址,网卡地址等
- Linux下获取公网IP地址
- asp.net(c#)获取内容第一张图片地址的函数
- 【网络应用】批处理获取本机的公网IP地址
- 获取windows未导出函数地址标准方法
- KiFastCallEntry() 函数地址的获取
- 获取当前浏览器地址的函数