ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2019-06-22 00:05:03  阅读:370  来源: 互联网

标签:c wifi windows-7 rssi ssid


我是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的包装容易得多
希望这可以帮助

标签:c,wifi,windows-7,rssi,ssid
来源: https://codeday.me/bug/20190621/1259039.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有