如何识别网络接口是LAN还是Wifi或外部 [英] How to identify if the Network Interface is LAN or Wifi or External

查看:178
本文介绍了如何识别网络接口是LAN还是Wifi或外部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想区分我的系统上可用的以太网。
这是一个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屋!

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