Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to write a vb program to find all connected network devices to my computer.
all devices which is connected to my computer use IPv4 and am trying to find the devices IP adresses.

how can i do?

thanks

Maybe you didnt undrestand whaat i need really,
I need the a list and ip of physical devices which is connected to my computer, not the program and services of local computer
Posted
Updated 29-Dec-12 0:30am
v2

1 solution

Do you really want to write it for yourself?
Since there are lots of free tools outside, able to tell you this. See Sysinternals TCPview[^] for example, or the built-in windows tool NETSTAT[^].

But it is really not complicated at all, check out this article:
http://towardsnext.wordpress.com/2009/02/09/netstat-in-c/[^]

[Update]
Here is the vb.net version of it:
VB
Imports System
Imports System.Net
Imports System.Net.NetworkInformation

Module Program
	Sub Main()
		Dim ipProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()

			Dim endPoints As IPEndPoint() = ipProperties.GetActiveTcpListeners()
			Dim tcpConnections As TcpConnectionInformation() = ipProperties.GetActiveTcpConnections()

			For Each info As TcpConnectionInformation In tcpConnections
				Console.WriteLine("Local : " & info.LocalEndPoint.Address.ToString() & ":" & info.LocalEndPoint.Port.ToString() & vbLf & "Remote : " & info.RemoteEndPoint.Address.ToString() & ":" & info.RemoteEndPoint.Port.ToString() & vbLf & "State : " & info.State.ToString() & vbLf & vbLf)
			Next
			Console.ReadLine()
	End Sub
End Module
 
Share this answer
 
v2
Comments
MehdiFadaei 29-Dec-12 5:50am    
Yes, i want to write because this is a part of my program.
really the code which you supported dosnt work. at the moment my compter is connected to home group via wireless and also a device is connected to my computer via ethernet port. my computer ip for wireless is 192.168.1.7 and for ethernet is 10.0.0.100
the connecterd devices to wireless: another computers: 192.168.1.2 to 6
the connected device to lan 10.0.0.241

but this program is not able to find these devices
MehdiFadaei 29-Dec-12 6:25am    
thanks but dosnt work anymore
Zoltán Zörgő 29-Dec-12 11:06am    
is netstat showing you what you want?
Zoltán Zörgő 29-Dec-12 12:19pm    
As I see, your question is wrong. What you want is not the list of devices connected to your computer, you want to list the devices connected to your networks. That is something else.
A device is connected to your computer if there is any socket opened between the remote device and your machine, that is what you can list this way, and that is what you asked for.
MehdiFadaei 29-Dec-12 13:52pm    
Really you are right, iam looking for the devices which are connected to my networks. sorry. how can i solve it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900