Bon, j'ai personnellement tapé "VB6 GetIfTable" dans Bing et j'ai aisément trouvé <cet exemple> qui semble fonctionner
Pour faire la recherche de l'index à partir de l'IP, il te suffit de stocker les infos dans un tableau et de faire une boucle.
Parmi les données reccueillies, il ne semble pas y avoir l'adresse IP mais seulement l'adresse MAC.
Tu peux utiliser ce genre de code pour récupérer l'adresse MAC en fonction de l'IP :
Déclaration :
Private Const NO_ERROR As Long = &H0
Private Const ERROR_BAD_NET_NAME As Long = &H43
Private Const ERROR_BUFFER_OVERFLOW As Long = &H6F
Private Const ERROR_GEN_FAILURE As Long = &H1F
Private Const ERROR_INVALID_PARAMETER As Long = &H57
Private Const ERROR_INVALID_USER_BUFFER As Long = &H6F8
Private Const ERROR_NOT_FOUND As Long = &H490
Private Const ERROR_NOT_SUPPORTED As Long = &H32
Private Declare Function ConvertIPtoLong Lib "wsock32.dll" Alias "inet_addr" (ByVal s As String) As Long
Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As Long, ByVal SrcIP As Long, pMacAddr As Long, PhyAddrLen As Long) As Long
Private Declare Sub ConvertByteArrayToLong Lib "kernel32" Alias "RtlMoveMemory" (dst As Byte, src As Long, ByVal bcount As Long)
Code :
Public Function GetRemoteMACAddress(ByRef RemoteIP As String, _
ByRef ReturnedMacAddress As String, _
ByRef SeparationChar As String) As Boolean
Dim dwRemoteIP As Long
Dim pMacAddr As Long
Dim bpMacAddr() As Byte
Dim PhyAddrLen As Long
Dim lResponse As Long
GetRemoteMACAddress = False ' par défaut
dwRemoteIP = ConvertIPtoLong(RemoteIP)
If dwRemoteIP <> 0 Then
PhyAddrLen = 6
'Retrouver le Mac pour L'adresse IP ...
lResponse = SendARP(dwRemoteIP, 0&, pMacAddr, PhyAddrLen)
Select Case lResponse
Case NO_ERROR
If (pMacAddr <> 0) And (PhyAddrLen <> 0) Then
ReDim bpMacAddr(0 To PhyAddrLen - 1)
ConvertByteArrayToLong bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
ReturnedMacAddress = FormatMacAddress(bpMacAddr(), SeparationChar)
If Len(ReturnedMacAddress) > 0 Then
If Left$(ReturnedMacAddress, 1) <> "(" Then
GetRemoteMACAddress = True
End If
Else
ReturnedMacAddress = "Récupération adresse MAC impossible (Ipv6 ?)"
End If
End If
Case ERROR_BAD_NET_NAME
ReturnedMacAddress = "(GetRemoteMACAddress) Réseau inaccessible."
Case ERROR_BUFFER_OVERFLOW
ReturnedMacAddress = "(GetRemoteMACAddress) Adresse MAC attendue trop longue."
Case ERROR_GEN_FAILURE
ReturnedMacAddress = "(GetRemoteMACAddress) Adresse réseau cible ou réseau inaccessible."
Case ERROR_INVALID_PARAMETER
ReturnedMacAddress = "(GetRemoteMACAddress) Paramètre invalide."
Case ERROR_INVALID_USER_BUFFER
ReturnedMacAddress = "(GetRemoteMACAddress) Buffer invalide."
Case ERROR_NOT_FOUND
ReturnedMacAddress = "(GetRemoteMACAddress) Elément non trouvé."
Case ERROR_NOT_SUPPORTED
ReturnedMacAddress = "(GetRemoteMACAddress) Fonction non supportée par le système."
Case Else
ReturnedMacAddress = "(GetRemoteMACAddress) Erreur non prise en charge : &H" & Hex(lResponse) & "."
End Select
End If
End Function
Private Function FormatMacAddress(btAddress() As Byte, sDelim As String) As String
Dim r As Long
Dim sTemp As String
On Local Error GoTo Erreur
' Jusqu'à présent, les adresses MAC font 6 segments, de 0 à 5
If UBound(btAddress) = 5 Then
' Agrège les segments avec le séparateur fourni
For r = 0 To 4
sTemp = sTemp & Right$("00" & Hex(btAddress(r)), 2) & sDelim
Next
sTemp = sTemp & Right$("00" & Hex(btAddress(5)), 2)
End If
' Résultat
FormatMacAddress = sTemp
Fin:
Exit Function
Erreur:
FormatMacAddress = "(FormatMacAddress) Erreur " & Err.Number & " - " & Err.Description
Resume Fin
End Function