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 ...
随机推荐
- 【无旋 treap】例题
[bzoj3223]文艺平衡树 Description 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[ ...
- JSP和Servlet学习笔记1 - 访问配置
1. 访问 WebContent 目录下的 JSP 文件 在 WebContent 目录下的文件可以直接在浏览器中访问.新建一个 test.jsp 文件 <%@ page language=&q ...
- 如何向数据库添加时同时返回ID
我们在做项目开发时很多时候都需要数据库的增删改查,而添加数据后又想得到该项数据在数据库中的主键值,这里有一个非常方便的方法可以在插入数据的同时获得主键值. public void save(Perso ...
- PAT 1001-1010 题解
早期部分代码用 Java 实现.由于 PAT 虽然支持各种语言,但只有 C/C++标程来限定时间,许多题目用 Java 读入数据就已经超时,后来转投 C/C++.浏览全部代码:请戳 本文谨代表个人思路 ...
- visio(2013)绘图工具的使用
1. 链接线 ⇒ 直线 visio2010中如何使画出来的连接线为直线 [设计面板] ⇒ 在最右端将[链接线]设置为直线: 2. 连接线交叉而不产生交叉桥(弯曲) visio2013画图时两条直线交叉 ...
- 获取当前div中的所有div的个数和每一个div的ID and 根据屏幕分辨率计算高度
var tabs_Count=document.getElementById("tabs-panels").getElementsByTagName("div" ...
- CSS动作
5.过渡 tansition (由一个状态过渡到另外一个状态的过程) transition 过渡 参数1: ...
- <模拟电子学习1>Multisim 12.0 结构和仿真51最小的单芯片系统
周围环境: 系统环境: win7 64位置 软件平台:Multisim 12.0 目的: 刚毕业,可是模电知识也忘得差点儿相同了,加之自己想搞搞硬件设计.假设仅仅是看模电书.不实践,还是终觉浅.当做兴 ...
- WPF 3D模型的一个扩展方法
原文:WPF 3D模型的一个扩展方法 在WPF 3D中,我们常常需要改变一个ModelVisual3D对象的颜色. 先说说ModelVisual3D,本质上3D模型都是由一个个的三角形构成的,并且经过 ...
- 使用WPF实现3D场景[二]
原文:使用WPF实现3D场景[二] 在上一篇的文章里我们知道如何构造一个简单的三维场景,这次的课程我将和大家一起来研究如何用代码,完成对建立好了的三维场景的观察. 首先看一下DEMO的界面: ...