如何使用C#获取Win7的SSID和RSSI

我是Win7和WMI的新手。 请告诉我从WiFi到哪里查看有效接入点以及如何为每个接入点获取ssid / rssi。

我用过:

ManagementClass mc = new ManagementClass("root\\WMI", "MSNdis_80211_ServiceSetIdentifier", null); ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(@"root\wmi","SELECT * FROM MSNdis_80211_BSSIList"); 

但我得到0结果。 这个类是否支持Win7? 有人可以帮忙吗?

我有一个类似的问题,我需要获得当前连接的Wifi网络的SSID,但由于其复杂性,不想为API创建一个包装器,所以想到为什么不使用netsh

  ProcessStartInfo info = new ProcessStartInfo("netsh", "wlan show interfaces"); info.WorkingDirectory = @"%WINDIR%\system32"; info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; info.CreateNoWindow = true; info.RedirectStandardOutput = true; info.UseShellExecute = false; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo = info; proc.Start(); 

然后你可以从proc.StandardOutput.ReadToEnd()中检索输出; 从字符串中解析出你想要的东西:

 "\r\n There is 1 interface on the system: \r\n\r\n Name : Wireless Network Connection\r\n Description : Atheros AR9285 Wireless Network Adapter\r\n GUID : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r\n Physical address : xx:xx:xx:xx:xx:xx\r\n State : connected\r\n SSID : Dynex2\r\n BSSID : xx:xx:xx:xx:xx:xx\r\n Network type : Infrastructure\r\n Radio type : 802.11g\r\n Authentication : WPA2-Personal\r\n Cipher : CCMP\r\n Connection mode : Auto Connect\r\n Channel : 1\r\n Receive rate (Mbps) : 54\r\n Transmit rate (Mbps) : 54\r\n Signal : 100% \r\n Profile : Dynex2 \r\n\r\n Hosted network status : Not available\r\n\r\n" 

解析字符串要比为API编写包装更容易希望这会有所帮助

您可以使用Managed Wifi API代替WMI。

检查此问题获取我在Windows Vista上使用C#.Net连接的无线网络的SSID

有时候我用delphi-prism写一个例子,与C#非常相似。 http://theroadtodelphi.wordpress.com/2009/09/30/detecting-wifi-networks-using-delphi-prism/