赞
踩
#include <wlanapi.h>
#pragma comment(lib, "wlanapi.lib")
#pragma comment(lib, "ole32.lib")
WlanOpenHandle
WlanEnumInterfaces
HANDLE hClient = NULL; DWORD dwMaxClient = 2; DWORD dwCurVersion = 0; DWORD dwResult = 0; PWLAN_INTERFACE_INFO_LIST pIfList = NULL; dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient); if (ERROR_SUCCESS != dwResult) { qDebug() << "WlanOpenHandle failed with error:" << dwResult; //return false; } dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList); if (ERROR_SUCCESS != dwResult) { qDebug() << "WlanEnumInterfaces failed with error" << dwResult; //return false; }
WlanQueryInterface: 判断是否有已连接的wifi
PWLAN_CONNECTION_ATTRIBUTES pConnectInfo = NULL; DWORD connectInfoSize = sizeof(WLAN_CONNECTION_ATTRIBUTES); WLAN_OPCODE_VALUE_TYPE opCode = wlan_opcode_value_type_invalid; PWLAN_INTERFACE_INFO pIfInfo = NULL; pIfInfo = (WLAN_INTERFACE_INFO*)&pIfList->InterfaceInfo[i]; QString CurConnectedWlanProfileName{ "" }; if (pIfInfo->isState == wlan_interface_state_connected) { dwResult = WlanQueryInterface(hClient, &pIfInfo->InterfaceGuid, wlan_intf_opcode_current_connection, NULL, &connectInfoSize, (PVOID *)&pConnectInfo, &opCode); if (dwResult != ERROR_SUCCESS) { qDebug() << "WlanQueryInterface failed with error" << dwResult; } else { switch (pConnectInfo->isState) { case wlan_interface_state_connected: { // 配置文件名和wifi名相同 CurConnectedWlanProfileName = QString::fromWCharArray(pConnectInfo->strProfileName); qDebug() << &#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。