Code: Select all
Structure ADDRESS
IpLong.l
IpString.s
MacString.s
MacLength.l
MacArray.b[6]
EndStructure
Procedure.l GetIPAddresses(usrList.ADDRESS(), HostName.s = "")
Protected wsa.WSADATA, *host.HOSTENT
If WSAStartup_(1<<8|1, wsa) = #NOERROR
*host = gethostbyname_(HostName)
WSACleanup_()
If *host
For i = 0 To *host\h_length - 1
If AddElement(usrList())
usrList()\IpLong = PeekL(PeekL(*host\h_addr_list)+(i*SizeOf(Long)))
usrList()\IpString = IPString(usrList()\IpLong)
usrList()\MacLength = SizeOf(ADDRESS\MacArray)
If SendARP_(usrList()\IpLong, 0, @usrList()\MacArray, @usrList()\MacLength) = #NO_ERROR
For j = 0 To usrList()\MacLength - 2
usrList()\MacString + RSet(Hex(usrList()\MacArray[j] & 255), 2, "0") + ":"
Next
usrList()\MacString + RSet(Hex(usrList()\MacArray[j] & 255), 2, "0")
EndIf
EndIf
Next
EndIf
EndIf
ProcedureReturn CountList(usrList())
EndProcedure
NewList list.ADDRESS()
If GetIPAddresses(list())
ForEach list()
Debug "IP: " + list()\IpString
Debug "MAC: " + list()\MacString
Next
EndIf





