WMI scan all available APs returns garbage RRS feed

  • Question

  • dear ;

    i hope to scan all a vailable APs and get there MAC address and RSSI , so for that i have used WMI but i have a problem that the first result is ok but the second AP is just a garbage , so anyone have any idea to resolve this problem is very welcome.

    this is the code used:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Management;
    using System.Collections;
    using System.Net;
    namespace The_Wifi_Project
      class Program
        static void Main(string[] args)
              CNX.Service MyService = new Service();
              string scope = "root\\WMI";
              string query = "SELECT * FROM MSNDis_80211_BSSIList WHERE Active=True";
              ManagementObjectSearcher mos = new ManagementObjectSearcher(scope, query);
              ManagementObjectCollection moc = mos.Get();
              ManagementObjectCollection.ManagementObjectEnumerator moe = moc.GetEnumerator();
              /*Adapter name*/
              Console.WriteLine("Adapter: " + moe.Current.Properties["InstanceName"].Value);
              /*Number of available wireless networks*/
              Console.WriteLine("Available wireless networks: " + moe.Current.Properties["NumberOfItems"].Value);
              ManagementBaseObject[] objarr = (ManagementBaseObject[])moe.Current.Properties["Ndis80211BSSIList"].Value;
              foreach (ManagementBaseObject queryObj in objarr)
                string ssidString = BitConverter.ToString((byte[])queryObj["Ndis80211SsId"]);
                Console.WriteLine("SSID: ", ssidString);
                uint u_rssi = (uint)queryObj["Ndis80211Rssi"];
                int rssi = (int)u_rssi;
                string RSSID = rssi.ToString();
                Console.WriteLine(" RSSI: " + rssi.ToString());
                string MAC = BitConverter.ToString((byte[])queryObj["Ndis80211MacAddress"]);
                Console.WriteLine(" MAC: " + MAC);
    • Moved by Paul Zhou Tuesday, April 26, 2011 5:10 AM off-topic (From:.NET Base Class Library)
    Tuesday, April 19, 2011 9:25 AM

All replies