Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to get all IP addresses and computernames from Local LAN.

I am waiting for your reply

Please help me thank you

Old Question title : Balakrishnan Dhinakaran I need your help
Posted
Updated 19-Dec-11 22:51pm
v3

VB
string myHost = System.Net.Dns.GetHostName();

                 System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);

                 // Loop through all IP addresses and display each 

                 foreach (System.Net.IPAddress myIP in myIPs.AddressList)
                 {
listBox2.Items.Add (myIP.ToString());


[edit]code block added[/edit]
 
Share this answer
 
v2
Comments
Nelek 11-Nov-12 16:26pm    
Did you notice that this question is from December 2011?
C#
private List<string> GetIpAddressFromHostName(List<string> ListHostNames)
        {
            List<string> ListIpAddress = new List<string>();

            foreach (var a in ListHostNames)
            {
                IPAddress[] ips;

                try
                {
                    ips = Dns.GetHostAddresses(a);

                    foreach (IPAddress ip1 in ips)
                    {
                        if (ip1.ToString().StartsWith("192.168."))
                        {
                            ListIpAddress.Add(ip1.ToString());
                        }
                    }
                }
                catch
                { 
                }
            }
            return ListIpAddress;
        }
 
Share this answer
 
v2
Comments
Dave Kreskowiak 4-Mar-14 10:22am    
Did you see that this question is over 2 years old??
KUMAR619 3-Apr-14 6:02am    
What to give for ListHostNames
in the above method

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900