Reputation: 12656
On Windows, how can I determine which Wifi WLAN interface returned by WlanGetAvailableNetworkList()
is connected?
I am successfully using WlanGetAvailableNetworkList()
on Windows 8 to scan for a list of Wifi WLAN access points and determine their SSID, BSSID, signal strength, and other information. I am following the example on this MSDN reference page.
Yet, for all the interfaces WLAN_INTERFACE_INFO
I receive, I cannot determine how to tell which access point, if any, is currently connected (i.e. wlan_interface_state_connected
).
On the Mac, I use scanForNetworksWithSSID
from the CoreWLAN
foundation, and the result has a connected bssid
field which I can compare with each bssid
from the scan results to determine which one of them is connected. I am looking for a similar Windows solution.
Thanks!
Upvotes: 5
Views: 3424
Reputation: 12656
Answer:
The answer is to use WlanQueryInterface()
(operationally similar to and used in parallel with WlanGetAvailableNetworkList()
) to determine the WLAN_CONNECTION_ATTRIBUTES and WLAN_ASSOCIATION_ATTRIBUTES of the connected adapter. There is an example demonstrating the use of WlanQueryInterface()
in the MSDN documentation at the bottom of this page.
I solved the problem by calling WlanQueryInterface()
to determine the connectedSSID
of the connected Wifi WLAN Adapter, if there is one. Then, I compare it with the SSID
values for each of the Adapters referenced in WlanGetAvailableNetworkList()
. A match, if there is one, determines the scanned adapter that is connected.
Note: I could also have compared BSSID values for a similar and possibly more reliable result.
Upvotes: 6