locked
Troubles with getting correct SSIDs via WMI RRS feed

  • Question

  • I'm trying to retreive all available wifi networks via WMI interface (in C#). Problem is, that I can read correctly only first network SSID. Every other SSID is corrupted, I get only few strange characters.

    For example:
    This 2 networks are available:
    1. ap123456
    2. julein-x

    Result:
    ap123456
    dap123456$0Hld0%

    The second SSID seems to be a little similar to the first one, but I can't find any mistake (overflow...).


    Here is my code sample:

    ConnectionOptions co = new ConnectionOptions();

    System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\localhost\\root\\wmi");

    System.Management.ObjectQuery query = new System.Management.ObjectQuery("SELECT * FROM MSNDis_80211_BSSIList");
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(ms, query);
    ManagementObjectCollection moc = searcher.Get();
    ManagementObjectCollection.ManagementObjectEnumerator moe = moc.GetEnumerator();
    moe.MoveNext();
    ManagementBaseObject[] objarr = (ManagementBaseObject[])moe.Current.Properties["Ndis80211BSSIList"].Value;

    foreach (ManagementBaseObject obj in objarr)
    {
      byte[] ssidb = (byte[])obj["Ndis80211Ssid"];
      char[] ssidc = Encoding.ASCII.GetChars(ssidb);
      String ssid = new String(ssidc);
      Console.WriteLine(ssid);
    }




    Thank you very much for any help.
    Wednesday, October 24, 2007 12:42 PM