11

我正在编写一个小型网络管理工具。为了提取各种 WiFi 网络的详细信息,我正在调用wlanapi.dll, WlanGetProfile(...)API 方法来获取每个可用 WiFi 网络的配置文件信息。

假设两个本地 WiFi 网络有相似的 SSID,我如何在这两个网络上查询信息并在向用户展示信息时区分两者?

我正在用 C# 编写我的应用程序,但是,如果它们能给我所需的答案,则可以提供非特定于代码的通用细节。但是,我将其标记为 C#/.Net,因为如果有办法使用本机 .Net 库获取此信息,我将不胜感激 C# 代码示例。

4

3 回答 3

4

检测具有相同 SSID 的少数网络没有问题,因为它们具有不同的 MAC。

但是,看起来无法连接到选定的一个,因为在连接时无法指定 MAC。

于 2018-04-06T06:34:13.743 回答
1

此代码项目示例相同的链接:A-Vista-Wireless-Network-Scanner

在此处输入图像描述

Process proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = "netsh";
proc.StartInfo.Arguments = "wlan show networks mode=bssid";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();

与mac连接:

//// Connects to a known network with WEP security
string profileName = "Cheesecake"; // this is also the SSID
string mac = "52544131303235572D454137443638";
string key = "hello";
string profileXml = string.Format("<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><hex>{1}</hex><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>WEP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>networkKey</keyType><protected>false</protected><keyMaterial>{2}</keyMaterial></sharedKey><keyIndex>0</keyIndex></security></MSM></WLANProfile>", profileName, mac, key);

wlanIface.SetProfile(Wlan.WlanProfileFlags.AllUser, profileXml, true);
wlanIface.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName);
于 2018-04-12T03:07:14.967 回答
0

具有相同 SSID 的不同网络仍将具有不同的 MAC 地址。

这也适用于同一网络的不同接入点。

不幸的是,我不知道如何查询 MAC 地址供您检查。

于 2018-04-09T12:02:39.563 回答