Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

List all network computers by both name and ip?

I have incomplete code, help...

 DirectoryEntry root = new DirectoryEntry("WinNT:");
            foreach (System.DirectoryServices.DirectoryEntry dDom in root.Children)
            {
                foreach (System.DirectoryServices.DirectoryEntry dPC in dDom.Children)
                {
                    listBox1.Items.Add(dDom.Name + "/" + dPC.Name);
                }
            }        
0
kvnsdr
Asked:
kvnsdr
  • 2
1 Solution
 
RedKelvinCommented:
0
 
kvnsdrAuthor Commented:
Nice but, List all network computers by both name and ip?

I cannot locate any code on the Internet that lists all network computer by IP address.
0
 
RedKelvinCommented:
No worries, that code returns all the names, you can resolve the IP address using the machine name using Dns.Resolve

IPHostEntry hostInfo = Dns.Resolve(hostString);

IPAddress[] address = hostInfo.AddressList;

Hoststring is the machine name

http://msdn2.microsoft.com/en-us/library/system.net.dns.resolve(VS.71).aspx
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now