I have some problems getting valid/readable data from the WMI classes handling wireless network information. Here's what I got:
This the correct info I want:
Is WMI ****ed up, or am I doing something wrong here?
About the RSSI, I know I can get it in dBm from "MSNdis_80211_RecievedSignalStrength" property, but that's ONLY for the CONNECTED accesspoint.
This the correct info I want:
Code:
[color=Blue] public static void[/color] GetAvailableNetworks()
{
[color=Blue]try[/color]
{
[color=SeaGreen] /*Making the search*/[/color]
[color=Blue]string[/color] scope = [color=DarkRed]"root\\WMI"[/color];
[color=Blue]string[/color] query = [color=DarkRed]"SELECT * FROM MSNdis_80211_BSSIList"[/color];
[color=DeepSkyBlue]ManagementObjectSearcher[/color] mos = [color=Blue]new[/color] [color=DeepSkyBlue]ManagementObjectSearcher[/color](scope, query);
[color=DeepSkyBlue]ManagementObjectCollection[/color] moc = mos.Get();
[color=DeepSkyBlue]ManagementObjectCollection[/color].[color=DeepSkyBlue]ManagementObjectEnumerator[/color] moe = moc.GetEnumerator();
moe.MoveNext();
[color=SeaGreen]/*Adapter name*/[/color]
[color=DeepSkyBlue]Console[/color].WriteLine([color=DarkRed]"Adapter: "[/color] + moe.Current.Properties[[color=DarkRed]"InstanceName"[/color]].Value);
[color=SeaGreen]/*Number of available wireless networks*/[/color]
[color=DeepSkyBlue]Console[/color].WriteLine([color=DarkRed]"Available wireless networks: "[/color] + moe.Current.Properties[[color=DarkRed]"NumberOfItems"[/color]].Value);
[color=DeepSkyBlue]ManagementBaseObject[/color][] objarr = ([color=DeepSkyBlue]ManagementBaseObject[/color][]) moe.Current.Properties[[color=DarkRed]"Ndis80211BSSIList"[/color]].Value;
[color=Blue]foreach[/color] ([color=DeepSkyBlue]ManagementBaseObject[/color] queryObj [color=Blue]in[/color] objarr)
{
[color=SeaGreen]/*One SSID per line (SSID = name of nerwork)*/[/color]
[color=DeepSkyBlue]Console[/color].WriteLine([color=DeepSkyBlue]Encoding[/color].ASCII.GetChars(([color=Blue]byte[/color][])queryObj.Properties[[color=DarkRed]"Ndis80211Ssid"[/color]].Value));
[color=SeaGreen] /*
* Other info:
* Ndis80211Ssid (Service Set Identifer) (array of uint8) = byte[]
* Ndis80211MacAddress (array of uint8) = byte[]
* Ndis80211Rssi (Recieved Signal Strength Identifier) (uint32) (Must be converted to dBm :/)
*/[/color]
}
}
[color=Blue]catch[/color] ([color=DeepSkyBlue]ManagementException[/color] e)
{
[color=DeepSkyBlue]Console[/color].WriteLine([color=DarkRed]"An error occurred while querying for WMI data: "[/color] + e.Message);
}
}
Is WMI ****ed up, or am I doing something wrong here?
About the RSSI, I know I can get it in dBm from "MSNdis_80211_RecievedSignalStrength" property, but that's ONLY for the CONNECTED accesspoint.