找回密码
 加入
搜索
查看: 3636|回复: 10

获取IP地址

[复制链接]
发表于 2008-5-8 09:56:59 | 显示全部楼层 |阅读模式
如何写获取宽带拨号连接后自动分配到的IP地址.
发表于 2008-5-8 10:13:41 | 显示全部楼层
#include <INet.au3>
_GetIP ( )
发表于 2008-5-8 11:01:53 | 显示全部楼层
获取本地公网IP的函数。
官方提供的UDP不是很好用,所以修改了一下。增加了多网站支持。

$begin = TimerInit()
$ip = _GetIP()
msgbox(0,TimerDiff($begin),$ip)

Func _GetIP()
$ipurl = 'http://ip.91cool.net/ip.php?type=ip' & @cr & _
  'http://www.123cha.com/ip/' & @cr & _
  'http://www.ip138.com/' & @cr & _
  'http://www.whatismyip.com'
$url = StringSplit($ipurl, @cr)
For $i = 1 to $url[0]
  If InetGet($url[$i], @TempDir & "\~ip.tmp") Then
  $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
  FileDelete(@TempDir & "\~ip.tmp")
  $ip = StringRegExp($ip, '((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)', 2)
  if not @error then Return $ip[0]
EndIf
Next
SetError(1)
Return -1
EndFunc
 楼主| 发表于 2008-5-9 17:18:00 | 显示全部楼层
那还是要通过远程的检测IP网站反馈呢。
发表于 2008-5-17 19:25:45 | 显示全部楼层
最简单的就是用宏了
MsgBox(0,"当前的ip为",@IPAddress1)
发表于 2008-7-9 17:36:06 | 显示全部楼层
用宏很方便
发表于 2008-7-9 17:54:38 | 显示全部楼层
原帖由 bob 于 2008-5-17 19:25 发表
最简单的就是用宏了
MsgBox(0,"当前的ip为",@IPAddress1)



对,我正想:楼上几位那么高手,我该不该意思说用这个呢?
发表于 2008-7-10 01:34:38 | 显示全部楼层
MsgBox(0,"当前的ip为",@IPAddress1)    那是本地网卡的IP地址
发表于 2008-7-10 08:44:02 | 显示全部楼层
三楼正解。。。
发表于 2010-5-16 10:25:32 | 显示全部楼层
用@IPAddress1不准确!
发表于 2010-7-28 14:14:35 | 显示全部楼层
还是用不来
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-3 12:26 , Processed in 0.104275 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表