Question Mac address

just369

Member
Joined
May 12, 2010
Messages
17
Programming Experience
Beginner
VB.NET:
Declare Function SendARP Lib "iphlpapi.dll" Alias "SendARP" (ByVal DestIP As Int32, ByVal SrcIP As Int32, ByVal pMacAddr() As Byte, ByRef PhyAddrLen As Int32) As Int32

    Public Shared Function GetMac(ByVal ipAddr As String) As String

        Dim macAddress As String = String.Empty
        Try
            Dim destIP As Net.IPAddress = Net.IPAddress.Parse(ipAddr)
            Dim IP() As Byte = destIP.GetAddressBytes()
            Dim IPInt As Int32 = BitConverter.ToInt32(IP, 0)
            Dim mac() As Byte = New Byte(5) {}
            SendARP(IPInt, 0, mac, mac.Length)
            macAddress = BitConverter.ToString(mac, 0, mac.Length)
        Catch ex As Exception
            Debug.Write(ex.Message)
        End Try
        Return macAddress
    End Function

this is my code to get mac address with a given ip....but i get results 00000 after i ping anything above 37 10.131.37.52

when i ping 10.131.37 (anything) i get the mac but if i ping 10.131.(42 - wtvr).(anything)

i get mac 000000000
 
Back
Top