Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to get a list of computer names in LAN

how to get a list of computer names in LAN

Scheduled Pinned Locked Moved C#
questionsysadmintutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vinziee
    wrote on last edited by
    #1

    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 :)

    B 1 Reply Last reply
    0
    • V Vinziee

      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 :)

      B Offline
      B Offline
      Bharat Jain
      wrote on last edited by
      #2

      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 Integer

          Dim 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

      B 1 Reply Last reply
      0
      • B Bharat Jain

        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 Integer

            Dim 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

        B Offline
        B Offline
        Bharat Jain
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups