Menu

Retrieving Wifi Access Point Information in C#

January 8, 2017 - .NET, C#

When I wrote BCNetMenu, it was primarily for replacing Windows 10’s built in network foldout for VPN connections. However since that Network foldout also managed Wireless connections, I decided to add that in as well.

When you have a need that would be filled by a library, it’s always a good idea to look through results on NuGet and see what there is. As with most requirements there are many options when it comes to reading Access Point information. In my case, I settled on SimpleWifi

The Consumer code for SimpleWifi is, well, Simple, which is one of the reasons I opted for it. It provides the information needed and was quite easy to use. Here is an example static that provides an enumerator method that retrieves Access Points:

I found there was an odd issue with this approach. it seemed as if AP info would “trickle” in over time; the second time I opened the menu there would be more access points. I don’t know why that was, but I added a bit of extra code with the intent of providing a larger set of “seed” networks when the menu is opened for the first time. It seems like the act of inspecting Access Points causes more to be actually added. At any rate this is the logic I added to the start of the GetWirelessConnections() logic:

This appeared to rectify my problems, and the Menu that used this method was properly showing available wireless networks appropriately.

Have something to say about this post? Comment!