how to get a list of computer names in LAN
-
hi GURUs my myself Vinod i am an amature in network programming as an assignment for my final year i have picked up LAN messenger actually there are many questions but 1st things 1st * HOW DO I GET THE NAMES AND IPADDRESS OF ALL THE COMPUTERS IN MY OFFICE????????????????? * Desperately waitin for ur reply n thx a million in advance :)
-
hi GURUs my myself Vinod i am an amature in network programming as an assignment for my final year i have picked up LAN messenger actually there are many questions but 1st things 1st * HOW DO I GET THE NAMES AND IPADDRESS OF ALL THE COMPUTERS IN MY OFFICE????????????????? * Desperately waitin for ur reply n thx a million in advance :)
Hi Vinziee , You can try the following code , also do not forget to Import System.Net In the following example we use the service of DNS , first we find the host of current computer then try to get list of computer from this DNS. I hope this works .
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GetAllIP()
End Sub
Public Function GetAllIP() As IntegerDim strHostName As New String("") strHostName = Dns.GetHostName() Console.WriteLine("Local Machine's Host Name: " + strHostName) Dim ipEntry As IPHostEntry = Dns.GetHostEntry(strHostName) Dim addr As IPAddress() = ipEntry.AddressList Dim i As Integer = 0 While i < addr.Length TextBox1.Text = TextBox1.Text & vbCrLf & String.Format("IP Address {0}: {1} ", i, addr(i).ToString()) System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) Application.DoEvents() End While Return 0 End Function
-Regards Bharat Jain bharat.jain.nagpur@gmail.com
-
Hi Vinziee , You can try the following code , also do not forget to Import System.Net In the following example we use the service of DNS , first we find the host of current computer then try to get list of computer from this DNS. I hope this works .
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GetAllIP()
End Sub
Public Function GetAllIP() As IntegerDim strHostName As New String("") strHostName = Dns.GetHostName() Console.WriteLine("Local Machine's Host Name: " + strHostName) Dim ipEntry As IPHostEntry = Dns.GetHostEntry(strHostName) Dim addr As IPAddress() = ipEntry.AddressList Dim i As Integer = 0 While i < addr.Length TextBox1.Text = TextBox1.Text & vbCrLf & String.Format("IP Address {0}: {1} ", i, addr(i).ToString()) System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) Application.DoEvents() End While Return 0 End Function
-Regards Bharat Jain bharat.jain.nagpur@gmail.com
Sorry the previous code is in Vb , i hope you will be able to convert it . It is very simple
-Regards Bharat Jain bharat.jain.nagpur@gmail.com