![]() |
|
|||||||
| Net / Sockets Components for network and related use |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
I'm currently working on an application that first pings and then, if something "pings back", checks the ip-address using the GetHostEntry statement. If a device is connected at ex. IP 192.168.1.50, it pops up on a list. But I was wondering... Is it possible to get the name of that device? GetHostEntry only gives me the IP-address (unless its a computer, then the computer name pops up) if it find a router, modem, a mobile device etc... For example: I have a dreambox connected on my network. Is there a way to get the name of the dreambox when i know its ip??? Or my Nokia? Or my wireless printer??? I'm uploading a picture of the application so you might better understand what i mean. PS: The text in the application is in Norwegian...
__________________
best regards _ powerade_ |
|
||||
|
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:
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)
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.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
i have a question which may lead to another question, but here's the first...
how can i get the name of the computer/machine using IP address ex. the computer's name is alien with ip address 192.168.0.10 now i have a program which pings the network Try Dim IncreaseValue As Integer = 1 Dim Ping As New Ping Dim PingOptions As New PingOptions PingOptions.Ttl = 64 Dim PingRep As PingReply While (IncreaseValue <= 256) Dim IPAddPC = IpAddressPopulate & IncreaseValue.ToString PingRep = Ping.Send(IPAddPC, 10) TextBox1.AppendText(PingRep.Status.ToString & " - " & IPAddPC & vbCrLf) If PingRep.Status = IPStatus.Success Then ListBox1.Items.Add(IpAddressPopulate & IncreaseValue) ' & " - Computer responded.") Else ListBox1.Items.Add(IpAddressPopulate & IncreaseValue) '& " - Computer did not respond.") End If IncreaseValue += 1 End While Catch ex As Exception End Try I have another listbox which lists all the ip address that respond to ping. My problem now is how to retrieve the name of the computers/machines using that IP address. I did use the System.Net.Dns.GetHostEntry(listbox1.selecteditem. tostring).HostName but it returns the value of the ip address and not the name of the computer... inside the network we also have some network printers that i must also get the information... kindly help pls...
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
|
|
|||
|
follow-up:
i use this to get the information using the IP address Dim co As New ConnectionOptions() Dim ms As New System.Management.ManagementScope("\\" & Name & "\root\cimv2", co) Dim oqProcessor = New System.Management.ObjectQuery("SELECT * FROM Win32_Processor") Dim queryProcessor = New ManagementObjectSearcher(ms, oqProcessor) Dim queryCollectionProcessor = queryProcessor.[Get]() using the above code, i could get the information of the computers, however, i could not get the names of the machines(printer, access point)
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
|
|
|||
|
i also tried the Win32_NetworkAdapter (just a little thought: i thought all machines have this property
) but to no avail...
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
|
|
|||
|
another follow-up, i hope this will be the last follow-up...
another thing inside our network, we have computers that have different operating system... for sure i could ping them but how can i get them name and information...??? i'm very sorry for the readers here, im just a newbie so please bear with me...
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
|
|
|||
|
Hi, try this:
Code:
Imports System.Net Code:
Dim hostNameOrAddress As String = YourIPadress Dim returnValue As IPHostEntry Try returnValue = Dns.GetHostEntry(hostNameOrAddress) MessageBox.Show(returnValue.HostName()) Catch ex As Exception MessageBox.Show(ex.Message) End Try
__________________
best regards _ powerade_ Last edited by _powerade_; 03-04-2009 at 7:07 AM. |
|
|||
|
Quote:
thanks for your reply. unfortunately, when i tried this code that you had given, it only returns the given ip address. what i needed is that, if that ip address was assigned to a, for example, a network printer or a router, it will display, either the name of the router or some kind of description. thanks anyway for the reply. it will be of useful future reference.
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
|
|
||||
|
alienation, did you read post 2 before posting in this thread?
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|