0

我试图弄清楚如何通过 C# 代码确定我与远程计算机的通信是使用 WLAN 卡还是本地计算机上的有线 NIC。

例如,通过 ODBC 连接到 SQL 数据库或 UNC 文件共享来访问远程机器。如何检测通信是通过 WLAN 还是有线 LAN 进行的?

目的是警告用户该应用程序不喜欢通过 WLAN 与远程机器通信。

我对常规的 C#+.NET Framework 解决方案持开放态度,但如果有帮助,也可以使用 WMI。

下一步是确定访问是否通过 WAN/VPN 连接,但主要问题是第一个问题。

弗罗德

4

1 回答 1

0

Use the network information types/WMI to get routing information having done a name lookup to get all the IP addresses of the remote machine.

However, this will only ever be a guesstimate. It is quite possible for packets from your machine to go over a wired LAN, and return packets to go across the WLAN. Because it is the routing table on the remote system that determines which interface it uses and this is a local resource.

于 2009-02-25T11:42:57.470 回答