我正在局域网中连接所有系统名称。我不知道如何获取所有系统名称的IP地址,例如(192.168.1.15)。
这可能会帮你
foreach(NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
{
if(!ip.IsDnsEligible)
{
if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
// All IP Address in the LAN
}
}
}
}
此代码的唯一缺点是的实例返回的信息UnicastIPAddressInformation
不适用于Windows XP之前的操作系统。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句