找回密码
 加入
搜索
楼主: freedom

[系统综合] 关于IP地址获取的问题。

 火.. [复制链接]
发表于 2011-7-14 15:43:23 | 显示全部楼层
本帖最后由 xiehuahere 于 2011-7-14 15:45 编辑

可以用WMI,不用include什么头文件。
$vpnip = get_ip("4235")
If $vpnip = "" Then
         MsgBox(4096, "Error", "VPN not detected!")
         Exit
EndIf

Func get_ip($networkadapter_name)
        Local $oIP = ""
        $strComputer = "."
        $objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\CIMV2")
        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL")
        For $objItem In $colItems
                If StringInStr($objItem.Description, $networkadapter_name) > 0 And $objItem.IPAddress <> "" Then
                        $oIP = $objItem.IPAddress(0)
                        ExitLoop
                EndIf
        Next

        Return $oIP
EndFunc
发表于 2011-7-14 22:06:32 | 显示全部楼层
回复 15# freedom


    嗯, WIN7 的回显不太一样啊, 我这里没有测试条件, 你按我的方法试试吧。
发表于 2011-7-14 23:29:16 | 显示全部楼层
用 ipconfig 的方式依赖于操作系统语言。
我这里也有个例子:
http://www.autoitx.com/thread-26105-1-1.html
 楼主| 发表于 2011-7-29 19:30:22 | 显示全部楼层
回复 16# xiehuahere


检测不到连接!
Windows7 Sp1
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-20 09:57 , Processed in 0.076586 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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