找回密码
 加入
搜索
查看: 3402|回复: 1

[网络通信] XP系统每次连接 接口列表都不一样怎么获取?

[复制链接]
发表于 2013-6-1 16:56:19 | 显示全部楼层 |阅读模式
本帖最后由 风雨网络 于 2013-6-1 17:05 编辑

winxp win2003  系统每次连接 接口列表都不一样怎么获取?  图中0x20004 每次都不一样!



这个是论坛找的代码
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_UseUpx=n
#PRE_UseX64=n
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Const $IPHLPAPI = DllOpen("iphlpapi.dll")
Const $tagMIB_IPFORWARDROW = "long Destination;long NetworkMask;long Policy;long NextHop;long IfIndex;long Type;long Proto;long Age;long NextHopAS;long Metric1;long Metric2;long Metric3;long Metric4;long Metric5"

Func _EnumIpForwordEntries()
        Local $iResult, $tBuffer, $tBinary, $pBinary, $tNumberofEntries, $aResult[1][14] = [[0]]

        $iResult = DllCall($IPHLPAPI, "long", "GetIpForwardTable", "ptr", 0, "long*", 0, "bool", 1)
        If ($iResult[2] < 4) Then Return SetError($iResult[0], 0, $aResult)

        $tBinary = DllStructCreate("ubyte Binary[" & $iResult[2] & "]")
        $pBinary = DllStructGetPtr($tBinary)

        $iResult = DllCall($IPHLPAPI, "long", "GetIpForwardTable", "ptr", $pBinary, "long*", $iResult[2], "bool", 1)
        If ($iResult[0]) Then Return SetError($iResult[0], 0, $aResult)

        $tNumberofEntries = DllStructCreate("long NumberofEntries", $pBinary)
        $aResult[0][0] = DllStructGetData($tNumberofEntries, "NumberofEntries")
        Redim $aResult[$aResult[0][0] + 1][14]

        For $i = 1 To $aResult[0][0]
                $tBuffer = DllStructCreate($tagMIB_IPFORWARDROW, $pBinary + 4 + ($i - 1) * 56)

                For $j = 0 To 13
                        $aResult[$i][$j] = DllStructGetData($tBuffer, $j + 1)
                Next
                $aResult[$i][0] = _ConvertUlongToChars($aResult[$i][0])
                $aResult[$i][1] = _ConvertUlongToChars($aResult[$i][1])
                $aResult[$i][3] = _ConvertUlongToChars($aResult[$i][3])
        Next

        Return $aResult
EndFunc ;==>_EnumIpForwordEntries

Func _ConvertUlongToChars($iUlong)
        Local $iResult = DllCall("Ws2_32.dll", "str", "inet_ntoa", "ulong", $iUlong)
        Return $iResult[0]
EndFunc ;==>_ConvertUlongToChars

Func _ConvertCharsToUlong($sChars)
        Local $iResult = DllCall("Ws2_32.dll", "long", "inet_addr", "str", $sChars)
        Return $iResult[0]
EndFunc ;==>_ConvertCharsToUlong

Func _CreateIpForwardEntry($sDestination, $sNetworkMask, $sNextHop, $iIfIndex, $iType, $iMetric)
        Local $tBuffer, $iResult

        If $iIfIndex = -1 Then $iIfIndex = _GetBestInterface($sNextHop)

        $tBuffer = DllStructCreate($tagMIB_IPFORWARDROW)
        DllStructSetData($tBuffer, "Destination", _ConvertCharsToUlong($sDestination))
        DllStructSetData($tBuffer, "NetworkMask", _ConvertCharsToUlong($sNetworkMask))
        DllStructSetData($tBuffer, "NextHop", _ConvertCharsToUlong($sNextHop))
        DllStructSetData($tBuffer, "IfIndex", $iIfIndex)
        DllStructSetData($tBuffer ,"Type", $iType)
        DllStructSetData($tBuffer, "Proto", 3)
        DllStructSetData($tBuffer, "Policy", 0)
        DllStructSetData($tBuffer, "Age", 0)
        DllStructSetData($tBuffer, "NextHopAS", 0)
        DllStructSetData($tBuffer, "Metric1", $iMetric)
        DllStructSetData($tBuffer ,"Metric2", -1)
        DllStructSetData($tBuffer ,"Metric3", -1)
        DllStructSetData($tBuffer ,"Metric4", -1)
        DllStructSetData($tBuffer ,"Metric5", -1)

        $iResult = DllCall($IPHLPAPI, "long", "CreateIpForwardEntry", "ptr", DllStructGetPtr($tBuffer))
        Return SetError($iResult[0], 0, $iResult[0] = 0)
EndFunc ;==>_CreateIpForwardEntry

Func _DeleteIpForwardEntry($sDestination, $sNetworkMask, $sNextHop, $iIfIndex, $iProto = 3)
        Local $iResult, $tBuffer

        If $iIfIndex = -1 Then $iIfIndex = _GetBestInterface($sNextHop)

        $tBuffer = DllStructCreate($tagMIB_IPFORWARDROW)
        DllStructSetData($tBuffer, "Destination", _ConvertCharsToUlong($sDestination))
        DllStructSetData($tBuffer, "NetworkMask", _ConvertCharsToUlong($sNetworkMask))
        DllStructSetData($tBuffer, "NextHop", _ConvertCharsToUlong($sNextHop))
        DllStructSetData($tBuffer, "IfIndex", $iIfIndex)
        DllStructSetData($tBuffer, "Proto", $iProto)

        $iResult = DllCall($IPHLPAPI, "long", "DeleteIpForwardEntry", "ptr", DllStructGetPtr($tBuffer))
        Return SetError($iResult[0], 0, $iResult[0] = 0)
EndFunc ;==>_DeleteIpForwardEntry

Func _GetBestInterface($sAddress)
        Local $iResult

        $iResult = DllCall($IPHLPAPI, "long", "GetBestInterface", "long", _ConvertCharsToUlong($sAddress), "long*", 0)
        Return SetError($iResult[0], 0, $iResult[2])
EndFunc ;==>_GetBestInterface

If _CreateIpForwardEntry("221.239.208.1", "255.255.255.255", "192.168.0.215", -1, 3, 60) Then
        MsgBox(48, "OK", "Done")
Else
        MsgBox(48, "Error", "Failed with error " & @error)
EndIf

If _DeleteIpForwardEntry("221.239.208.1", "255.255.255.255", "192.168.0.215", -1) Then
        MsgBox(48, "OK", "Done")
Else
        MsgBox(48, "Error", "Failed with error " & @error)
EndIf

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-6-1 18:40:32 | 显示全部楼层
回复 1# 风雨网络
$pid = Run(@ComSpec & ' /c route print', '', @SW_HIDE, 0x2)
ProcessWaitClose($pid)
$text = StringRegExpReplace(StdoutRead($pid), '(?ism).+^(0x\d+).+?WAN.+', '\1')
MsgBox(0, '', $text) 
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-4 17:56 , Processed in 0.078239 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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