WMI to get SSID and signal strength information

T

Toby Webb

Hi, can anyone help please?

I am trying to get infromation from my wireless card, such as signal
strength and a list of SSIDs that it can see. I have been able to get
the signal strength (see code below), but I cannot get the list of
SSIDs. I have installed WMITools (from Microsoft) to delve in further
and it tells me that there is no instance for MSNdis_80211_WLanBssId
or MSNdis_80211_BSSIList.

The code I used to get the signal strength is below:

----------------------------------------------------------------------------

ListBox2.Items.Clear()
Dim query As Management.ManagementObjectSearcher
Dim Qc As Management.ManagementObjectCollection
Dim Oq As Management.ObjectQuery
Dim Ms As Management.ManagementScope
Dim Co As Management.ConnectionOptions
Dim Mo As Management.ManagementObject
Dim signalStrength As String
Try
Co = New Management.ConnectionOptions
Ms = New Management.ManagementScope("root\wmi")
Oq = New Management.ObjectQuery("SELECT * FROM
MSNdis_80211_ReceivedSignalStrength Where active=true")
query = New Management.ManagementObjectSearcher(Ms, Oq)
Qc = query.Get
signalStrength = 0

For Each Mo In query.Get

signalStrength = Mo("Ndis80211ReceivedSignalStrength")
ListBox2.Items.Add(signalStrength)
Next
Catch exp As Exception
' Indicate no signal
signalStrength = -1
End Try

----------------------------------------------------------------------------


I have tried to use the same code but replacing the signal strength
table with the others I have mentioned but it returns no results
(instances). Can anyone please explain why, and if there is a way
around this?

I am using Win XP SP2.

Thanks in advance,

Toby.
 
J

jp2msft

Toby Webb said:
Hi, can anyone help please?

I am trying to get infromation from my wireless card, such as signal
strength and a list of SSIDs that it can see. I have been able to get
the signal strength (see code below), but I cannot get the list of
SSIDs. I have installed WMITools (from Microsoft) to delve in further
and it tells me that there is no instance for MSNdis_80211_WLanBssId
or MSNdis_80211_BSSIList.

The code I used to get the signal strength is below:

----------------------------------------------------------------------------

ListBox2.Items.Clear()
Dim query As Management.ManagementObjectSearcher
Dim Qc As Management.ManagementObjectCollection
Dim Oq As Management.ObjectQuery
Dim Ms As Management.ManagementScope
Dim Co As Management.ConnectionOptions
Dim Mo As Management.ManagementObject
Dim signalStrength As String
Try
Co = New Management.ConnectionOptions
Ms = New Management.ManagementScope("root\wmi")
Oq = New Management.ObjectQuery("SELECT * FROM
MSNdis_80211_ReceivedSignalStrength Where active=true")
query = New Management.ManagementObjectSearcher(Ms, Oq)
Qc = query.Get
signalStrength = 0

For Each Mo In query.Get

signalStrength = Mo("Ndis80211ReceivedSignalStrength")
ListBox2.Items.Add(signalStrength)
Next
Catch exp As Exception
' Indicate no signal
signalStrength = -1
End Try

----------------------------------------------------------------------------


I have tried to use the same code but replacing the signal strength
table with the others I have mentioned but it returns no results
(instances). Can anyone please explain why, and if there is a way
around this?

I am using Win XP SP2.

Thanks in advance,

Toby.

Developing on Win XP SP2, right? WMI = "Windows Mobile Interface"?

Anyway, we have Symbol Pocket PC devices here. They have WiFi cards in them,
but they are not managed by Windows. We can open the wireless settings, and
the Pocket PC OS does not show that the wireless is activated or even
available.

We had to go to the manufacturer.

Unfortunately, the Symbol company has been bought and sold many times, so
even the current manufacturer did not have an SDK that could address our
products.

Hopefully, you won't run into this.
 
K

kimiraikkonen

Developing on Win XP SP2, right? WMI = "Windows Mobile Interface"?

Anyway, we have Symbol Pocket PC devices here. They have WiFi cards in them,
but they are not managed by Windows. We can open the wireless settings, and
the Pocket PC OS does not show that the wireless is activated or even
available.

We had to go to the manufacturer.

Unfortunately, the Symbol company has been bought and sold many times, so
even the current manufacturer did not have an SDK that could address our
products.

Hopefully, you won't run into this.

It must be "Windows Management Instrumentation" to access low-level
hardware info provided by System.Management.dll. However, based on
OP's description, it would be wiser to catch the exception to
understand what kind of problem it would be, possibly it can be "not
supported" or anything else which is hardware dependant issue.

For example, including some modern multi-core PCs, when you query
"Win32_Fan" or "MSAcpi_ThermalZoneTemperature" in "root\WMI" scope you
get nothing or "not supported" error:
http://groups.google.com/group/micr...hl=en&lnk=st&q=not+supported#0506b4a40cf31ea6

So, follow these to ensure if the query is really supported:
1)Start -> Run
2)type "wbemtest"
3)Click on "Connect" and enter "root\WMI"
4)Click on "Query" and paste your query syntax.

See what output you'll get, again, it may not be related to your code.

Hope this helps,

Onur Güzel
 
T

Toby Webb

It must be "Windows Management Instrumentation" to access low-level
hardware info provided by System.Management.dll. However, based on
OP's description, it would be wiser to catch the exception to
understand what kind of problem it would be, possibly it can be "not
supported" or anything else which is hardware dependant issue.

For example, including some modern multi-core PCs, when you query
"Win32_Fan" or "MSAcpi_ThermalZoneTemperature" in "root\WMI" scope you
get nothing or "not supported" error:http://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

So, follow these to ensure if the query is really supported:
1)Start -> Run
2)type "wbemtest"
3)Click on "Connect" and enter "root\WMI"
4)Click on "Query" and paste your query syntax.

See what output you'll get, again, it may not be related to your code.

Hope this helps,

Onur Güzel- Hide quoted text -

- Show quoted text -

Thanks for both of your help. I have found out that it is the wireless
card that doesn't support these methods (instead I have to use
Ather5000_ namespace instead of MSNDis).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top