BOOL CWlanApiInvoker::WlanGetNetworkBssList( __in HANDLE hClientHandle, __in const GUID* pInterfaceGuid, __in_opt const PDOT11_SSID pDot11Ssid, __in DOT11_BSS_TYPE dot11BssType, __in BOOL bSecurityEnabled, PVOID pReserved, __out PWLAN_BSS_LIST* ppWlanBssList ) { if (!IsLibLoaded()) { return FALSE; } PWlanGetNetworkBssList pWlanGetNetworkBssList=(PWlanGetNetworkBssList)GetProcAddress(m_hWlanLib,"WlanGetNetworkBssList"); if (NULL==pWlanGetNetworkBssList) { return FALSE; } return pWlanGetNetworkBssList(hClientHandle,pInterfaceGuid,pDot11Ssid, dot11BssType,bSecurityEnabled,pReserved,ppWlanBssList)==ERROR_SUCCESS; }
void WiFiInfo::Impl::GetApnsAndNotifyClient() { vector<WiFiInfo::AccessPoint> apns; PWLAN_INTERFACE_INFO_LIST pIfList = NULL; DWORD dwResult = WlanEnumInterfaces(m_hClient, NULL, &pIfList); if (dwResult == ERROR_SUCCESS) { for (int ifIndex = 0; ifIndex < static_cast<int>(pIfList->dwNumberOfItems); ++ifIndex) { PWLAN_INTERFACE_INFO pIfInfo = (PWLAN_INTERFACE_INFO)&pIfList->InterfaceInfo[ifIndex]; PWLAN_BSS_LIST pWlanBssList = NULL; if (pWlanGetNetworkBssList) { // on WinXP we don't have this function :( dwResult = pWlanGetNetworkBssList(m_hClient, &pIfInfo->InterfaceGuid, 0, dot11_BSS_type_any, FALSE, NULL, &pWlanBssList); if (dwResult == ERROR_SUCCESS) { for (int wlanIndex = 0; wlanIndex < static_cast<int>(pWlanBssList->dwNumberOfItems); ++wlanIndex) { PWLAN_BSS_ENTRY pBssEntry = &pWlanBssList->wlanBssEntries[wlanIndex]; WiFiInfo::AccessPoint apn; apn.m_ssid.assign(&pBssEntry->dot11Ssid.ucSSID[0], &pBssEntry->dot11Ssid.ucSSID[pBssEntry->dot11Ssid.uSSIDLength]); char buff[20] = {}; sprintf(buff, "%02X-%02X-%02X-%02X-%02X-%02X", pBssEntry->dot11Bssid[0], pBssEntry->dot11Bssid[1], pBssEntry->dot11Bssid[2], pBssEntry->dot11Bssid[3], pBssEntry->dot11Bssid[4], pBssEntry->dot11Bssid[5]); apn.m_bssid = buff; sprintf(buff, "%ld", pBssEntry->lRssi); apn.m_signalStrength = buff; apns.push_back(apn); } WlanFreeMemory(pWlanBssList); } } } WlanFreeMemory(pIfList); } m_callback(apns); // on WinXP, clean up timer if it was used if (m_timer) { DeleteTimerQueueTimer(NULL, m_timer, NULL); m_timer = NULL; } }