Solved

List all network computers by both name and ip?

Posted on 2007-11-13
3
209 Views
Last Modified: 2010-04-15
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
Comment
Question by:kvnsdr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Expert Comment

by:RedKelvin
ID: 20277441
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 20277625
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
 
LVL 22

Accepted Solution

by:
RedKelvin earned 250 total points
ID: 20277956
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question