4

私は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 をサポートしていますか? 誰でも助けることができますか?

4

2 に答える 2

5

現在接続されている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 のラッパーを作成するよりも、文字列を解析する方がはるかに簡単です

于 2012-01-02T04:57:59.987 に答える
0

WMI の代わりにManaged Wifi APIを使用できます。

Windows Vista で C# .Net を使用して接続しているワイヤレス ネットワークの SSID を取得するこの質問を確認してください。

しばらくの間、私は Delphi-prism を使用して例を書きましたが、これは C# に非常に似ています。 http://theroadtodelphi.wordpress.com/2009/09/30/detecting-wifi-networks-using-delphi-prism/

于 2010-02-25T16:03:42.120 に答える