我有以下代码并尝试查找 AP 的 MAC 地址。代码运行,但它不返回任何内容。我究竟做错了什么?
using System;
using System.Management;
public class wifiTest
{
public static int Main(string[] args)
{
String query = "SELECT * FROM MSNDis_80211_BSSIList";
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root/WMI", query);
ManagementObjectCollection moc = searcher.Get();
ManagementObjectCollection.ManagementObjectEnumerator moe = moc.GetEnumerator();
moe.MoveNext();
ManagementBaseObject[] objarr = (ManagementBaseObject[])moe.Current.Properties["Ndis80211BSSIList"].Value;
foreach (ManagementBaseObject obj in objarr)
{
uint u_rssi = (uint)obj["Ndis80211Rssi"];
int rssi = (int)u_rssi;
int macAd = (int)obj["Ndis80211MacAddress"];
Console.WriteLine("RSSI=" + rssi);
Console.WriteLine("Mac=" + macAd);
}
return 0;
}
}