Howto retrieve MAC Address of Wireless Connections
I have been struggling to get a program working in Visual Basic 2005 that gets the MAC addresses of all of the wifi connections and then puts them in a list box. The code looks like this:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim query As String = "SELECT * FROM MSNDis_80211_BSSIList WHERE Active='True'"
Dim searcher As Management.ManagementObjectSearcher = New Management.ManagementObjectSearcher("root/WMI", query)
Dim moc As Management.ManagementObjectCollection = searcher.Get()
Dim moe As Management.ManagementObjectCollection.ManagementOb jectEnumerator =
Dim objarr() As Management.ManagementBaseObject = CType(moe.Current.Properties("Ndis80211BSSIList"). Value,
For Each obj As Management.ManagementBaseObject In objarr
Dim ssid() As Char = System.Text.Encoding.ASCII.GetChars(CType(obj("Ndi s80211MacAddress"), Byte()))
Sorry about the word wrap, but anyway, when I run the program, it doesn't show to addresses in the listbox. For each wireless connection, it just show a blank line.
So I was wondering what's wrong with this code. And, if this method isn't possible, is their any way to retrieve the MAC addresses in Visual Basic 2005?
Thanks for any help.
P.S. Sorry if this belongs in the Visual Basic beginner's forum. I wasn't sure where to put it.