How can I enumerate all available wireless networks and display them in a ListBox? [closed]
I have a problem regarding with C#. How to populate a listbox with those wireless networks which are found by the computer in C#?
You need to call the WlanGetAvailableNetworkList
function.
This fills in a WLAN_AVAILABLE_NETWORK_LIST
structure with information about all of the wireless networks that are available on the specified interface.
Once you have that, it's a simple matter of iterating through the array and adding each wireless network to your ListBox control.
This API is available as of Windows XP SP3, and is redistributable for clients running XP SP2 using the Wireless LAN API.
And rather than writing the P/Invoke definitions yourself, you could investigate the Managed Wifi API, which is a .NET class library that wraps most of these native functions for you already.
Use the Managed Wifi API which just wraps the Native Wifi Api. It's pretty easy to use to get the list of SSIDs. The method you want is
WlanInterface.GetAvailableNetworkList
which just wraps WlanGetAvailableNetworkList
.
From there you can put these into a ListBox
.
精彩评论