Windows 7中的NetworkInterface.GetAllNetworkInterfaces()提供错误的值 [英] NetworkInterface.GetAllNetworkInterfaces() giving wrong values in Windows 7

查看:298
本文介绍了Windows 7中的NetworkInterface.GetAllNetworkInterfaces()提供错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是用C#4.0开发的.
当我运行NetworkInterface.GetAllNetworkInterfaces()以获取NetworkConnections
我能够在Windows Xp计算机中获得此
像下面的
系统IP地址:192.168.34.211
系统子网掩码:255.255.248.0




但是在Windows 7中,它提供了很多垃圾网络连接:(
就像下面的



系统IP地址:fe80 :: 181c:7e45:865e:cef0%11
系统子网掩码:0.0.0.0

系统IP地址:192.168.34.211
系统子网掩码:255.255.248.0

系统IP地址:fe80 :: 5efe:192.168.34.211%12
系统子网掩码:0.0.0.0

系统IP地址:fe80 :: 100:7f:fffe%13
系统子网掩码:0.0.0.0




请告知
可能是什么原因?

My application is developed in C#4.0
when i run NetworkInterface.GetAllNetworkInterfaces() to get the NetworkConnections
i am able to get this in Windows Xp computer''s
like below
System IP Address: 192.168.34.211
System Subnet Mask: 255.255.248.0




but in the windows 7 it is giving lot of junk network connections :(
like below



System IP Address: fe80::181c:7e45:865e:cef0%11
System Subnet Mask: 0.0.0.0

System IP Address: 192.168.34.211
System Subnet Mask: 255.255.248.0

System IP Address: fe80::5efe:192.168.34.211%12
System Subnet Mask: 0.0.0.0

System IP Address: fe80::100:7f:fffe%13
System Subnet Mask: 0.0.0.0




please advise
what could be the reason ?

推荐答案

它给您的其他地址是IPv6地址和IPv4地址.

希望这对您有帮助
The other addresses it gives you are the IPv6 addresses as well as the IPv4 address.

Hope this helps


那些是IPV6地址(某些人可能认为是垃圾邮件).
Those are IPV6 addresses (which could be considered to be junk by some).


执行类似操作以过滤掉IPV6地址:

Do something like this to filter out the IPV6 addresses:

foreach (UnicastIPAddressInformation address in  ipInterfaceProperties.UnicastAddresses)
{
    if (address.Address.AddressFamily == AddressFamily.InternetworkV4)
    {
         ipAddressInfoList.Add(new IPNetworkInterfaceInfo(address.Address, address.IPv4Mask));
    }
}



顺便说一句,您可以在Google上轻松找到它.



BTW, you could have easily found this on google.


这篇关于Windows 7中的NetworkInterface.GetAllNetworkInterfaces()提供错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆