Option Explicit
Private Const ANY_SIZE = 16 ' сколько ожидается IP-адресов в системе
Private Type MIB_IPADDRROW
dwAddr(0 To 3) As Byte ' IP address
dwIndex As Long ' interface index
dwMask(0 To 3) As Byte ' subnet mask
dwBCastAddr(0 To 3) As Byte ' broadcast address
dwReasmSize As Long ' rassembly size
unused As Long ' not currently used
End Type
Private Type MIB_IPADDRTABLE
dwNumEntries As Long ' number of entries in the table
Table(1 To ANY_SIZE) As MIB_IPADDRROW ' array of IP address entries
End Type
Private Declare Function GetIpAddrTable Lib "iphlpapi" (pIpAddrTable As MIB_IPADDRTABLE, pdwSize As Long, ByVal bOrder As Long) As Long
Sub Main()
Dim Table As MIB_IPADDRTABLE, i As Long
If GetIpAddrTable(Table, Len(Table), 0) = 0 Then
With Table
For i = 1 To .dwNumEntries
With .Table(i)
Debug.Print "IP: " & .dwAddr(0) & "." & .dwAddr(1) & "." & .dwAddr(2) & "." & .dwAddr(3)
Debug.Print "Interface #: " & .dwIndex
Debug.Print "Subnet mask: " & .dwMask(0) & "." & .dwMask(1) & "." & .dwMask(2) & "." & .dwMask(3)
Debug.Print "Broadcast: " & .dwBCastAddr(0) & "." & .dwBCastAddr(1) & "." & .dwBCastAddr(2) & "." & .dwBCastAddr(3)
Debug.Print
End With
Next
End With
End If
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 114