How to identify if the Network Interface is LAN or Wifi or External(如何识别网络接口是 LAN 或 Wifi 还是外部)
问题描述
我想区分我系统上可用的以太网.无论是 LAN 、 Wifi 还是由 VMWare 创建的东西.我只对局域网感兴趣
.
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}
", networkInterface.Name, networkInterface.NetworkInterfaceType, networkInterface.Id);
}
现在我如何区分 NetworkInterface.Description
和 NetworkInterface.NetworkInterfaceType
没用.
Now how do I differentiate as NetworkInterface.Description
and NetworkInterface.NetworkInterfaceType
are not useful.
还有其他方法吗?
推荐答案
查看使用 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 还是外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何识别网络接口是 LAN 或 Wifi 还是外部
基础教程推荐
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01