D
dogalmity
None of the code segments I've seen on this will execute, they all give
me an
"invalid class" runtime error, either at the MoveNext() or the foreach.
Do I need to somehow tell WMI which adapter to try to get the SSID list
from? I've only got one wireless adapter.
This way gives me an unhandled exception when it tries to do the
GetInstance()
ManagementClass mc = new ManagementClass("root\\WMI",
"MSNdis_80211_ServiceSetIdentifier", null);
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc) //FAILS HERE
{
string wlanCard = (string)mo["InstanceName"];
bool active = (bool)mo["Active"];
byte[] ssid = (byte[])mo["Ndis80211SsId"];
string ssidString = Encoding.ASCII.GetString(ssid);
Console.WriteLine("{0}\r\n{1}\r\n{2}", wlanCard, active,
ssidString);
Console.WriteLine();
}
And doing it this way gives the same exception and also says Additional
Information: Invalid Class. It fails when it gets to MoveNext()
String query = "SELECT * FROM MSNDis_80211_BSSIList";
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("root/WMI", query);
ManagementObjectCollection moc = searcher.Get();
ManagementObjectCollection.ManagementObjectEnumerator moe =
moc.GetEnumerator();
moe.MoveNext(); //FAILS HERE
ManagementBaseObject[] objarr =
(ManagementBaseObject[])moe.Current.Properties["Ndis80211BSSIList"].Value;
foreach( ManagementBaseObject obj in objarr)
{
uint rs = (uint)obj["Ndis80211Rssi"];
listBox1.Items.Add((int)rs);
char[] ssid = Encoding.ASCII.GetChars((byte[])obj["Ndis80211Ssid"]);
listBox1.Items.Add(new String(ssid));
}
Anyone have thoughts? I'm in a real pickle here.
me an
"invalid class" runtime error, either at the MoveNext() or the foreach.
Do I need to somehow tell WMI which adapter to try to get the SSID list
from? I've only got one wireless adapter.
This way gives me an unhandled exception when it tries to do the
GetInstance()
ManagementClass mc = new ManagementClass("root\\WMI",
"MSNdis_80211_ServiceSetIdentifier", null);
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc) //FAILS HERE
{
string wlanCard = (string)mo["InstanceName"];
bool active = (bool)mo["Active"];
byte[] ssid = (byte[])mo["Ndis80211SsId"];
string ssidString = Encoding.ASCII.GetString(ssid);
Console.WriteLine("{0}\r\n{1}\r\n{2}", wlanCard, active,
ssidString);
Console.WriteLine();
}
And doing it this way gives the same exception and also says Additional
Information: Invalid Class. It fails when it gets to MoveNext()
String query = "SELECT * FROM MSNDis_80211_BSSIList";
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("root/WMI", query);
ManagementObjectCollection moc = searcher.Get();
ManagementObjectCollection.ManagementObjectEnumerator moe =
moc.GetEnumerator();
moe.MoveNext(); //FAILS HERE
ManagementBaseObject[] objarr =
(ManagementBaseObject[])moe.Current.Properties["Ndis80211BSSIList"].Value;
foreach( ManagementBaseObject obj in objarr)
{
uint rs = (uint)obj["Ndis80211Rssi"];
listBox1.Items.Add((int)rs);
char[] ssid = Encoding.ASCII.GetChars((byte[])obj["Ndis80211Ssid"]);
listBox1.Items.Add(new String(ssid));
}
Anyone have thoughts? I'm in a real pickle here.