【问题标题】:How to get SSID and RSSI for Win7 using C#如何使用 C# 获取 Win7 的 SSID 和 RSSI
【发布时间】:2011-01-20 20:30:15
【问题描述】:

我对 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吗?有人可以帮忙吗?

【问题讨论】:

    标签: c# windows-7 wifi rssi ssid


    【解决方案1】:

    我遇到了类似的问题,我需要获取当前连接的 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 编写包装器容易得多 希望这会有所帮助

    【讨论】:

    • 如何在 Windows XP 中使用?我认为命令在 XP 中不起作用,在 Winows 7 中起作用
    【解决方案2】:

    【讨论】:

    • Thanx RRUZ,实际上我已经使用托管 wifi api 但 wlan 函数似乎无法应用并返回“找不到类型或命名空间名称‘Wlan’(您是否缺少 using 指令或程序集参考?)”。我正在使用 Visual Studio 2010 和 Windows 7。Visual Studio 2010 中是否有任何功能可以帮助从 Windows 7 获取 SSID 和 RSSI。
    猜你喜欢
    • 2012-07-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-01
    • 1970-01-01
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多