QT---Native Wifi functions 应用(WiFi有密码连接)
- WLAN_NOTIFICATION_CALLBACK
- WlanAllocateMemory
- WlanCloseHandle
- WlanConnect
- WlanDeleteProfile
- WlanDisconnect
- WlanEnumInterfaces
- WlanExtractPsdIEDataList
- WlanFreeMemory
- WlanGetAvailableNetworkList
- WlanGetFilterList
- WlanGetInterfaceCapability
- WlanGetNetworkBssList
- WlanGetProfile
- WlanGetProfileCustomUserData
- WlanGetProfileList
- WlanGetSecuritySettings
- WlanHostedNetworkForceStart
- WlanHostedNetworkForceStop
- WlanHostedNetworkInitSettings
- WlanHostedNetworkQueryProperty
- WlanHostedNetworkQuerySecondaryKey
- WlanHostedNetworkQueryStatus
- WlanHostedNetworkRefreshSecuritySettings
- WlanHostedNetworkSetProperty
- WlanHostedNetworkSetSecondaryKey
- WlanHostedNetworkStartUsing
- WlanHostedNetworkStopUsing
- WlanIhvControl
- WlanOpenHandle
- WlanQueryAutoConfigParameter
- WlanQueryInterface
- WlanReasonCodeToString
- WlanRegisterNotification
- WlanRegisterVirtualStationNotification
- WlanRenameProfile
- WlanSaveTemporaryProfile
- WlanScan
- WlanSetAutoConfigParameter
- WlanSetFilterList
- WlanSetInterface
- WlanSetProfile
- WlanSetProfileCustomUserData
- WlanSetProfileEapUserData
- WlanSetProfileEapXmlUserData
- WlanSetProfileList
- WlanSetProfilePosition
- WlanSetPsdIeDataList
- WlanSetSecuritySettings
WLAN_profile Schema Elements [xml配置文件编写格式]:
- WLANProfile
- name (WLANProfile)
- SSIDConfig (WLANProfile)
- connectionType (WLANProfile)
- connectionMode (WLANProfile)
- autoSwitch (WLANProfile)
- MSM (WLANProfile)
- IHV (WLANProfile)
Wireless Profile Samples[无线配置文件例程]
- Bootstrap Profile Sample
- FIPS Profile Sample
- Non-Broadcast Profile Sample
- Single Sign-On Profile Sample
- WPA-Enterprise with PEAP-MSCHAPv2 Profile Sample
- WPA-Enterprise with TLS Profile Sample
- WPA-Personal Profile Sample
- WPA2-Enterprise with PEAP-MSCHAPv2 Profile Sample
- WPA2-Enterprise with TLS Profile Sample
- WPA2-Personal Profile Sample
<?xml version="1.0" encoding="US-ASCII"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>SampleWPA2PSK</name>
<SSIDConfig>
<SSID>
<name>SampleWPA2PSK</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<autoSwitch>false</autoSwitch>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey><keyType>passPhrase</keyType><protected>false</protected><keyMaterial> <!-- insert key here --> </keyMaterial></sharedKey>
</security>
</MSM></WLANProfile>
【加密类型设置】
<encryption>AES</encryption>
【安全类型设置】
<authentication>WPAPSK</authentication>
Value Description open Open 802.11 authentication. shared Shared 802.11 authentication. WPA WPA-Enterprise 802.11 authentication. WPAPSK WPA-Personal 802.11 authentication. WPA2 WPA2-Enterprise 802.11 authentication. WPA2PSK WPA2-Personal 802.11 authentication.
具体功能编程实现(QTCtreator 5.xx)
.pro文件
LIBS+=$$quote(E:/qt/2015-4-9/WlanGetProfileTest/WlanGetProfileTest/lib/wlanapi.lib)
LIBS+=$$quote(E:/qt/2015-4-9/WlanGetProfileTest/WlanGetProfileTest/lib/OLE32.lib)
包含头文件
#include<windows.h>
#include<wlanapi.h>
- 程序实现(终端打印信息)
- #include<windows.h>
- #include<wlanapi.h>
- #include<string>
- #include<stdio.h>
- //无线连接状态
- intlistenStatus()
- {
- HANDLEhClient=NULL;
- DWORDdwMaxClient=2;
- DWORDdwCurVersion=0;
- DWORDdwResult=0;
- intiRet=0;
- WCHARGuidString[39]={0};
- //ListenthestatusoftheAPyouconnected.
- while(1){
- Sleep(5000);
- PWLAN_INTERFACE_INFO_LISTpIfList=NULL;
- PWLAN_INTERFACE_INFOpIfInfo=NULL;
- dwResult=WlanOpenHandle(dwMaxClient,NULL,&dwCurVersion,&hClient);
- if(dwResult!=ERROR_SUCCESS){
- wprintf(L"WlanOpenHandlefailedwitherror:%u\n",dwResult);
- return1;
- }
- //获取无线网卡列表
- dwResult=WlanEnumInterfaces(hClient,NULL,&pIfList);
- if(dwResult!=ERROR_SUCCESS){
- wprintf(L"WlanEnumInterfacesfailedwitherror:%u\n",dwResult);
- return1;
- }else{
- wprintf(L"NumEntries:%lu\n",pIfList->dwNumberOfItems);
- wprintf(L"CurrentIndex:%lu\n\n",pIfList->dwIndex);
- inti;
- for(i=0;i<(int)pIfList->dwNumberOfItems;i++){
- pIfInfo=(WLAN_INTERFACE_INFO*)&pIfList->InterfaceInfo[i];
- wprintf(L"InterfaceIndex[%u]:\t%lu\n",i,i);
- iRet=StringFromGUID2(pIfInfo->InterfaceGuid,(LPOLESTR)&GuidString,
- sizeof(GuidString)/sizeof(*GuidString));
- if(iRet==0)
- wprintf(L"StringFromGUID2failed\n");
- else{
- wprintf(L"InterfaceGUID[%d]:%S\n",i,GuidString);
- }
- wprintf(L"InterfaceDescription[%d]:%S",i,
- pIfInfo->strInterfaceDescription);
- wprintf(L"\n");
- wprintf(L"InterfaceState[%d]:\t",i);
- switch(pIfInfo->isState){
- casewlan_interface_state_not_ready:
- wprintf(L"Notready\n");
- break;
- casewlan_interface_state_connected:
- wprintf(L"Connected\n");
- break;
- casewlan_interface_state_ad_hoc_network_formed:
- wprintf(L"Firstnodeinaadhocnetwork\n");
- break;
- casewlan_interface_state_disconnecting:
- wprintf(L"Disconnecting\n");
- break;
- casewlan_interface_state_disconnected:
- wprintf(L"Notconnected\n");
- break;
- casewlan_interface_state_associating:
- wprintf(L"Attemptingtoassociatewithanetwork\n");
- break;
- casewlan_interface_state_discovering:
- wprintf(L"Autoconfigurationisdiscoveringsettingsforthenetwork\n");
- break;
- casewlan_interface_state_authenticating:
- wprintf(L"Inprocessofauthenticating\n");
- break;
- default:
- wprintf(L"Unknownstate%ld\n",pIfInfo->isState);
- break;
- }
- }
- }
- }
- }
- intmain()
- {
- HANDLEhClient=NULL;
- DWORDdwMaxClient=2;
- DWORDdwCurVersion=0;
- DWORDdwResult=0;
- PWLAN_INTERFACE_INFO_LISTpIfList=NULL;
- //opensaconnectiontotheserver.
- dwResult=WlanOpenHandle(dwMaxClient,NULL,&dwCurVersion,&hClient);
- if(dwResult!=ERROR_SUCCESS){
- wprintf(L"WlanOpenHandlefailedwitherror:%u\n",dwResult);
- return1;
- }
- //enumeratesallofthewirelessLANinterfacescurrentlyenabledonthelocalcomputer.
- dwResult=WlanEnumInterfaces(hClient,NULL,&pIfList);
- if(dwResult!=ERROR_SUCCESS){
- wprintf(L"WlanEnumInterfacesfailedwitherror:%u\n",dwResult);
- return1;
- }else{
- //disconnectsaninterfacefromitscurrentnetwork.
- dwResult=WlanDisconnect(hClient,&pIfList->InterfaceInfo[0].InterfaceGuid,NULL);//DISCONNECTFIRST
- if(dwResult!=ERROR_SUCCESS)
- {
- printf("WlanDisconnectfailedwitherror:%lu\n",dwResult);
- return-1;
- }
- //retrievethelistofavailablenetworksonawirelessLANinterface.
- PWLAN_AVAILABLE_NETWORK_LISTpWLAN_AVAILABLE_NETWORK_LIST=NULL;
- dwResult=WlanGetAvailableNetworkList(hClient,&pIfList->InterfaceInfo[0].InterfaceGuid,
- 0,
- NULL,&pWLAN_AVAILABLE_NETWORK_LIST);
- if(dwResult!=ERROR_SUCCESS)
- {
- printf("WlanGetAvailableNetworkListfailedwitherror:%lu\n",dwResult);
- WlanFreeMemory(pWLAN_AVAILABLE_NETWORK_LIST);
- return-1;
- }
- //connectawlan
- LPCWSTRprofileXml;
- std::wstringstrHead=
- L"<?xmlversion=\"1.0\"encoding=\"US-ASCII\"?>\
- <WLANProfilexmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\">\
- <name>SampleWPA2PSK</name>\
- <SSIDConfig>\
- <SSID>\
- <name>CJLU</name>\
- </SSID>\
- </SSIDConfig>\
- <connectionType>ESS</connectionType>\
- <connectionMode>auto</connectionMode>\
- <autoSwitch>false</autoSwitch>\
- <MSM>\
- <security>\
- <authEncryption>\
- <authentication>WPA2PSK</authentication>\
- <encryption>AES</encryption>\
- <useOneX>false</useOneX>\
- </authEncryption>\
- <sharedKey>\
- <keyType>passPhrase</keyType>\
- <protected>false</protected>\
- <keyMaterial>5566778899</keyMaterial>\
- </sharedKey>\
- </security>\
- </MSM>\
- </WLANProfile>";
- profileXml=strHead.c_str();
- WLAN_REASON_CODEWlanreason;
- //如果<connectionMode>auto</connectionMode>,为自动连接,则下面的一步可以连接上无线
- dwResult=WlanSetProfile(hClient,
- &(pIfList->InterfaceInfo[0].InterfaceGuid),
- 0,profileXml,NULL,TRUE,NULL,&Wlanreason);
- if(ERROR_SUCCESS!=dwResult)
- {
- printf("wlansetprofilefailed%lu.\r\n",dwResult);
- }
- //删除无线配置文件
- /*
- LPCWSTRprofileName;
- LPCWSTRnewProfileName;
- std::wstringstrprofileName=L"SampleWPA2PSK";
- std::wstringstrNewProfileName=L"test";
- profileName=strprofileName.c_str();
- newProfileName=strNewProfileName.c_str();
- dwResult=WlanDeleteProfile(hClient,
- &(pIfList->InterfaceInfo[0].InterfaceGuid),
- profileName,NULL);
- if(ERROR_SUCCESS!=dwResult)
- {
- printf("wlandeleteprofilefailed%lu.\r\n",dwResult);
- }
- */
- /*
- //重命名无线配置文件,其实只是新建了一个配置文件,并无重命名(更改了wlanapi.h,将此函数换了条件编译位置)
- dwResult=WlanRenameProfile(hClient,
- &(pIfList->InterfaceInfo[0].InterfaceGuid),
- profileName,
- newProfileName,
- NULL
- );
- if(ERROR_SUCCESS!=dwResult)
- {
- printf("wlanRenameprofilefailed%lu.\r\n",dwResult);
- }
- */
- //网卡关闭和开启(关闭了,就开不了了,除非获取了InterfaceGuid
- //然后可以关闭再开启。用fn+F2手动开启)
- WLAN_PHY_RADIO_STATEstate;
- state.dwPhyIndex=0;
- state.dot11SoftwareRadioState=dot11_radio_state_on;
- PVOIDpData=&state;
- dwResult=WlanSetInterface(hClient,&pIfList->InterfaceInfo[0].InterfaceGuid,
- wlan_intf_opcode_radio_state,sizeof(WLAN_PHY_RADIO_STATE),pData,NULL);
- if(dwResult!=ERROR_SUCCESS)
- {
- wprintf(L"setstatefailed!erris%d\n",dwResult);
- }
- }
- dwResult=WlanCloseHandle(hClient,NULL);
- if(dwResult!=ERROR_SUCCESS)
- {
- wprintf(L"WlanCloseHandlefailed%lu.\r\n",dwResult);
- }
- listenStatus();
- if(pIfList!=NULL){
- WlanFreeMemory(pIfList);
- pIfList=NULL;
- }
- return0;
- }
http://blog.csdn.net/freeape/article/details/45954309
QT---Native Wifi functions 应用(WiFi有密码连接)的更多相关文章
- iOS能否自动扫描周边wifi信息并通过密码连接
能否获取系统wifi列表信息 不能,只能获取用户当前连接的wifi信息 https://developer.apple.com/forums/thread/112177 https://develop ...
- 小程序升级实时音视频录制及播放能力,开放 Wi-Fi、NFC(HCE) 等硬件连接功能
“ 小程序升级实时音视频录制及播放能力,开放 Wi-Fi.NFC(HCE) 等硬件连接功能.同时提供按需加载.自定义组件和更多访问层级等新特性,增强了第三方平台的能力,以满足日趋丰富的业务需求.” 0 ...
- atitit.无线上网卡 无法搜索WiFi 解决无线路由器信号不能被连接
atitit.无线上网卡 无法搜索WiFi 解决无线路由器信号不能被连接 #---现象 pc机无线网卡无法搜索到无线路由器的信号.. 但是,笔记本电脑和手机能够... 只要pc机无线网卡可以搜索信号, ...
- C#共享WIFI能通过代码控制给连接的移动端分配IP么
用C#创建了一个虚拟WIFI,但是能不能通过代码来给连接上的移动端分配各自的IP.之前都是自动分配的IP.望大神们赐教 C#共享WIFI能通过代码控制给连接的移动端分配IP么 >> csh ...
- 实时双频Wi-Fi如何实现下一代车内连接
实时双频Wi-Fi如何实现下一代车内连接 How real simultaneous dual band Wi-Fi enables next-generation in-vehicle connec ...
- 第15.19节 PyQt(Python+Qt)入门学习:自定义信号与槽连接
老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一.引言 本文利用中介绍了PyQt中的信号和槽机制,除了使用PyQt组件的已有信号外,PyQt和Qt ...
- 在Wifi网络中嗅探明文密码(HTTP POST请求、POP等)
全世界,现在大约50%的网站没有使用SSL加密,天朝尤其多. 我们都知道通过HTTP发送的数据都是明文,没有使用任何加密,即使是在数据敏感的登录页面. 本文的目的是:如果你在不熟悉的网络环境中,要注意 ...
- 无线渗透--wifiphisher之wifi钓鱼获取wifi密码
本来是想试验一下暴力破解的,但是由于字典太大,跑的时间也比较长,于是使用了钓鱼的方法. 先说一下wifiphisher钓鱼获取wifi密码的原理: wifiphisher对于你在攻击中选定的wifi会 ...
- 在linux,arm上的屏幕搜索wifi并连接(qt,多选择,wifi按信号排列)转
先上代码!! #include "widget.h"#include "ui_widget.h"#include <QVBoxLayout>#inc ...
随机推荐
- Opencv均值漂移pyrMeanShiftFiltering彩色图像分割流程剖析
meanShfit均值漂移算法是一种通用的聚类算法,它的基本原理是:对于给定的一定数量样本,任选其中一个样本,以该样本为中心点划定一个圆形区域,求取该圆形区域内样本的质心,即密度最大处的点,再以该点为 ...
- 【BZOJ 1034】[ZJOI2008]泡泡堂BNB
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1034 [题意] [题解] 如果己方最小的大于对方最小的(严格大于) 或己方最大的大于对 ...
- expdp备份速度慢的问题
--出口分析 --两个时间报表分析,该声明仅出口4,059,292 数据,10之后分钟数据没有继续出口 Snap Id Snap Time Sessions Curs ...
- DevCloud项目管理与Leangoo使用对比
DevCloud(华为软件开发云)是集华为研发实践.前沿研发理念.先进研发工具为一体的研发云平台,面向开发者提供端到端的研发工具服务.项目管理是DevCloud服务之一,致力于为敏捷开发团队提供简单高 ...
- WPF 渲染级别
原文:WPF 渲染级别 很少人会知道 WPF 也可以知道当前的显卡能支持的渲染级别. 根据显卡的不同,包括显存.纹理等的支持是否打到要求,指定渲染级别. 使用 System.Windows.Media ...
- 关于java项目与web项目中lib包的那点事
一.在java项目中如何引入外部jar包:1.在我们的java项目下新建一个lib文件夹:2.将我们需要引入的jat包复制到lib文件夹下:3.选中我们lib包下的jar,右键选择Build Path ...
- Light libraries是一组通用的C基础库,目标是为减少重复造轮子而写(全部用POSIX C实现)
Light libraries是一组通用的C基础库,目标是为减少重复造轮子而写实现了日志.原子操作.哈希字典.红黑树.动态库加载.线程.锁操作.配置文件.os适配层.事件驱动.工作队列.RPC.IPC ...
- 《大规模Web服务开发技术》
Web 服务开发的心灵鸡汤 周末去上海陪妹子的两天在路途上看完了这本<大规模 Web 服务开发技术>. <大规模 Web 服务开发技术>是日本的 Hetena 团队以夏天举办的 ...
- 获取当前div中的所有div的个数和每一个div的ID and 根据屏幕分辨率计算高度
var tabs_Count=document.getElementById("tabs-panels").getElementsByTagName("div" ...
- Cache memory power reduction techniques
Methods and apparatus to provide for power consumption reduction in memories (such as cache memories ...