473,394 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

using WMI to retrieve SSID - runtime errors

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.ManagementObjectEnumera tor 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.

May 3 '06 #1
0 3473

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erick Bodine | last post by:
I am trying to set a new environment variable on a W2k machine with only partial success. The name("SSID") and value("ASIM") show up correctly in the registry and when I go to "System...
6
by: Salvani Langosta | last post by:
In an Access 97 database, I use serveral global variables that hold information about the database, for example: gstrFileServer - holds the server root where the database is stored...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
0
by: Kevin | last post by:
Hi All Experts, Can any one tell me how to fetch the SSID value of AP in VC# programming language??? thanks & regards, Kevin
2
by: YRao | last post by:
I am going to create intranet application using Windows Authentication using C# asp.net I am having following problem: 1 setting windows Authentication, it will validate for all users, user...
3
by: Jay A. Moritz | last post by:
I have an application that loads IE and iterates through web pages to retrieve information from the page then activates specific controls to retrieve the next page and iterate through that page for...
6
by: justsee | last post by:
Hi, I'm using Python 2.3 on Windows for the first time, and am doing something wrong in using urllib to retrieve images from urls embedded in a csv file. If I explicitly specify a url and image...
0
by: Nils Hulsch | last post by:
Hello, I'm want to get the SSID of the current wireless network. After some searching on the web, I've found a solution by querying the WMI, but it seems that its not working on Vista anymore. ...
3
by: shigehiro | last post by:
Hi all, Further to my 'list of dictionaries' question yesterday, I would to ask how to write data to csv file format using 'list of dictionaries' as a source: data to be written to .csv file:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.