如何识别网络接口是LAN还是Wifi或外部 [英] How to identify if the Network Interface is LAN or Wifi or External
问题描述
我想区分我的系统上可用的以太网。
这是一个LAN,Wifi或由VMWare创建的东西。 我只是为int
I want to differentiate between the Ethernets available on my system.
Whether that's a LAN , Wifi or something created by VMWare. I am only intrested for LAN
.
但是当我枚举以下代码:
But when I am enumerating with following code:
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface networkInterface in adapters)
{
Console.WriteLine(" {0} ::: Interface Type {1} ::::ID {2} \n", networkInterface.Name, networkInterface.NetworkInterfaceType, networkInterface.Id);
}
现在我如何区分为 NetworkInterface.Description
和 NetworkInterface.NetworkInterfaceType
无用。
任何其他方式?
推荐答案
看看使用WMI检索更多详细信息网络适配器。它会告诉您给定的适配器是有线网络适配器还是无线网络适配器,以及它是否是物理网络适配器。
Look at using WMI to retrieve more detailed information about network adapters on the system. It'll tell you whether or not a given adapter is a wired network adapter or wireless, and if it is indeed a 'physical' network adapter.
http://geekswithblogs.net/PsychoCoder/archive/2008/01/25/using_wmi_in_csharp.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v = vs.85).aspx
这篇关于如何识别网络接口是LAN还是Wifi或外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!