View Single Post
  #2 (permalink)  
Old 09-24-2008, 9:07 AM
JohnH's Avatar
JohnH JohnH is offline
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,325
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

There could possibly be other ways and information when DNS host name is not available, but these could also mean more device specific interfacing. One global option is to get the MAC address, the first 3 bytes of these 6 is something called OUI (Organizationally Unique Identifier) and there exist a public list where you can at least find out which manufacturer produced the NIC, the other 3 bytes probably only each manufacturer know what means. Here is an example I have tested and which worked, you need this declaration:
Quote:
Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As Integer, ByVal SrcIP As Integer, ByRef pMacAddr As Long, ByRef PhyAddrLen As Integer) As Integer
The OUI list can be downloaded from IEEE.org.

Sample code to get MAC and OUI:
Code:
Dim ip As Integer = CInt(Net.IPAddress.Parse("192.123.45.67").Address)
Dim mem As Long
Dim ret As Integer = SendARP(ip, 0, mem, 6)
Dim ab() As Byte = BitConverter.GetBytes(mem)
Dim OUI As String = BitConverter.ToString(ab, 0, 3)
Nevermind the Address obsolete warning, also Vista runs IP4 compatibility translation.

With the OUI string you can search the text file or create yourself a smaller lookup table from it. When successful it is for example more useful to know this manufacturer name "CANON INC." than only the IP.
__________________
Reply With Quote