c#实现wifi连接器

前言

一般正常情况下都会用windows自带的wifi连接,但是为了给用户更好的体验,或者有时候需要检测wifi状态,还是需要集成到项目中态。

原理

1、微软自带Native Wifi API,不过是用C++的。

2、已有大神用c#封装了Native Wifi API,所以c#开发基于该封装,地址:http://managedwifi.codeplex.com/

3、连接前需要配置WLAN profile,如果连接失败,则要删除该配置。

4、也可以使用cmd命令

删除配置文件
在命令提示符下,键入:
netsh wlan delete profile name="ProfileName"
显示电脑上的所有无线配置文件
在命令提示符下,键入:
netsh wlan show profiles
显示安全密钥
在命令提示符下,键入:
netsh wlan show profile name="ProfileName" key=clear
停止自动连接到范围外的网络
在命令提示符下,键入:
netsh wlan set profileparameter name="ProfileName" connectionmode=manual(自动填auto)

实现

1、wifi列表tooltip显示详细信息

2、按照信号强度排序

3、连接状态显示

具体代码使用在项目里注释都非常清楚了

链接:http://pan.baidu.com/s/1eQlhH9S 密码:2alj

 

参考:

WLAN_profile Schema Elements https://msdn.microsoft.com/zh-cn/library/ms706965

Native Wifi https://msdn.microsoft.com/en-us/library/ms706556(v=vs.85).aspx

Wireless Profile Samples https://msdn.microsoft.com/zh-cn/library/aa369853

posted @ 2015-07-04 14:56  leestar54  阅读(7617)  评论(9编辑  收藏  举报