• Hallo, da ich die Funktion GetIpAddrTable brauchte, und im englischen Forum nur ein nicht mehr funktionierendes Beispiel aus dem Jahre 2006 zu finden war (hier), habe ich nun die Funktion neu geschrieben. Ich hoffe, das es jemand brauchen kann.

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $aIpTable = _GetIpAddrTable()
    _ArrayDisplay($aIpTable)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GetIpAddrTable($bOrder = 0)
    ;funkey 2013, Aug 17th
    Local Const $tagMIB_IPADDRROW = "STRUCT;DWORD dwAddr;DWORD dwIndex;DWORD dwMask;DWORD dwBCastAddr;DWORD dwReasmSize;USHORT unused1;USHORT wType;ENDSTRUCT;"
    Local Const $tagMIB_IPADDRTABLE = "DWORD dwNumEntries;" & $tagMIB_IPADDRROW

    [/autoit] [autoit][/autoit] [autoit]

    Local Const $MIB_IPADDR_PRIMARY = 0x0001
    Local Const $MIB_IPADDR_DYNAMIC = 0x0004
    Local Const $MIB_IPADDR_DISCONNECTED = 0x0008
    Local Const $MIB_IPADDR_DELETED = 0x0040
    Local Const $MIB_IPADDR_TRANSIENT = 0x0080

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRet, $dwSize, $dwNumEntries, $tMIB_IPADDRTABLE, $tagTemp = $tagMIB_IPADDRTABLE
    Local $iIpAddrRowSize = 24, $iSize = 28, $aTemp, $iTemp

    [/autoit] [autoit][/autoit] [autoit]

    $aRet = DllCall("iphlpapi.dll", "int", "GetIpAddrTable", "ptr", 0, "DWORD*", 0, "BOOL", $bOrder)
    $dwSize = $aRet[2]
    While $iSize < $dwSize
    $tagTemp &= $tagMIB_IPADDRROW
    $iSize += $iIpAddrRowSize
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    $tMIB_IPADDRTABLE = DllStructCreate($tagTemp)

    [/autoit] [autoit][/autoit] [autoit]

    $aRet = DllCall("iphlpapi.dll", "int", "GetIpAddrTable", "struct*", $tMIB_IPADDRTABLE, "DWORD*", $dwSize, "BOOL", $bOrder)
    If $aRet[0] <> 0 Then Return SetError(1, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    $dwNumEntries = DllStructGetData($tMIB_IPADDRTABLE, "dwNumEntries")

    [/autoit] [autoit][/autoit] [autoit]

    Local $aData[$dwNumEntries + 1][6] = [["Interface Index", "IP Address", "Subnet Mask", "Broadcast", "Reassembly size", "Type and State"]]
    For $i = 1 To $dwNumEntries
    $aData[$i][0] = DllStructGetData($tMIB_IPADDRTABLE, ($i - 1) * 7 + 3)
    $aTemp = DllCall("ws2_32.dll", "str", "inet_ntoa", "ptr", DllStructGetData($tMIB_IPADDRTABLE, ($i - 1) * 7 + 2))
    $aData[$i][1] = $aTemp[0]
    $aTemp = DllCall("ws2_32.dll", "str", "inet_ntoa", "ptr", DllStructGetData($tMIB_IPADDRTABLE, ($i - 1) * 7 + 4))
    $aData[$i][2] = $aTemp[0]
    $aTemp = DllCall("ws2_32.dll", "str", "inet_ntoa", "ptr", DllStructGetData($tMIB_IPADDRTABLE, ($i - 1) * 7 + 5))
    $aData[$i][3] = $aTemp[0]
    $aData[$i][4] = DllStructGetData($tMIB_IPADDRTABLE, ($i - 1) * 7 + 6)
    $iTemp = DllStructGetData($tMIB_IPADDRTABLE, ($i - 1) * 7 + 8)
    If BitAND($iTemp, $MIB_IPADDR_PRIMARY) Then $aData[$i][5] &= "Primary IP Address;"
    If BitAND($iTemp, $MIB_IPADDR_DYNAMIC) Then $aData[$i][5] &= "Dynamic IP Address;"
    If BitAND($iTemp, $MIB_IPADDR_DISCONNECTED) Then $aData[$i][5] &= "Address is on disconnected interface;"
    If BitAND($iTemp, $MIB_IPADDR_DELETED) Then $aData[$i][5] &= "Address is being deleted;"
    If BitAND($iTemp, $MIB_IPADDR_TRANSIENT) Then $aData[$i][5] &= "Transient address;"
    $aData[$i][5] = StringTrimRight($aData[$i][5], 1)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Return $aData
    EndFunc ;==>_GetIpAddrTable

    [/autoit]


    Schöne Grüße
    funkey