如何从本地LAN获取所有IP地址和计算机名称 [英] how to get all IP addresses and computernames from Local LAN
本文介绍了如何从本地LAN获取所有IP地址和计算机名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从本地局域网获取所有IP地址和计算机名。
我等待你的回复
请帮助我谢谢
旧问题标题:Balakrishnan Dhinakaran我需要你的帮助
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
推荐答案
http://www.dijksterhuis.org/finding -the-local-ip-addresses-in-c / [ ^ ]
http://stackoverflow.com/questions/151231/how-do-i-get-the- local-network-ip-address-of-a-computer-programmingmatically-c [ ^ ]
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]已添加的代码块[ / edit]
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;
}
这篇关于如何从本地LAN获取所有IP地址和计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文