Get information about the computers of a network .

Locked Get information about the computers of a network .

  • 2010年3月29日 17:28
     
     
    How to get computer names and IP(s) of a network (My Network) .    

全部回复

  • 2010年3月29日 17:40
     
     已答复
  • 2010年3月29日 18:26
     
     已答复
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.DirectoryServices;


    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                var computers = GetComputersOnNetwork();
            }


            static List<string> GetComputersOnNetwork()
            {
                List<string> list = new List<string>();
                using (DirectoryEntry root = new DirectoryEntry("WinNT:"))
                {
                    foreach (DirectoryEntry computers in root.Children)
                    {
                        foreach (DirectoryEntry computer in computers.Children)
                        {
                            if ((computer.Name != "Schema"))
                            {
                                list.Add(computer.Name);
                            }
                        }
                    }
                }
                return list;
            }
        }
    }

    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
  • 2010年3月29日 18:31
     
     已答复 包含代码
    // Get the hostname
    string myHost = System.Net.Dns.GetHostName();
    
    System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostByName(myHost);
    
    // Loop through all IP addresses and display each
    foreach(System.Net.IPAddress myIP in myIPs.AddressList)
    {
       MessageBox.Show(myIP.ToString());
    }


    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
  • 2010年3月29日 19:27
     
     已答复
    Also an implementation by Sacha Baeber at http://www.codeproject.com/KB/IP/ListNetworkComputers.aspx (Retreiving a list of network computer names using C# - CodeProject)
    My Blog - MSDN Complement By Providing Visual C# Walkthroughs and Sample Codes - Founded In February 24, 2010
  • 2010年3月30日 18:36
     
     

    Thanks you all ,,

    -------

  • 2012年8月20日 15:54