PC Review


Reply
Thread Tools Rate Thread

wmi and rssi wap question

 
 
billy
Guest
Posts: n/a
 
      10th Nov 2005
i've created the following code based on the classes i've found in the wmi
test console. it works however, both this code and in the wmi test console
it appears i'm getting two rssi signals from the same wifi nic...the first
has the "instancename" of the nic driver...the second is just a "?"...each
have differing signal strengths. can someone explain? also, will there
definitely always only be one "active" wifi nic at any given time? i don't
want to display information for one nic whilst another (wifi or not) is
really the one with the active network connection.

tia...here's the code (sorry for the text wrapping):

' ===============

Imports System.Management

Public Class Network

#Region " structures "

Public Structure WirelessAccessPoint
Dim NetworkCard As String
Dim SignalStrength As Long
Dim SSID As String
End Structure

#End Region

#Region " properties "

Public Shared ReadOnly Property Connected() As Boolean
Get
Try
Dim assignedIp As String =
GetHostByName(GetHostName()).AddressList(0).ToString
Return Not assignedIp = Net.IPAddress.Parse("127.0.0.1").ToString
Catch ex As Exception
Return False
End Try
End Get
End Property

#End Region

#Region " methods "

Public Shared Function WirelessAccessPoints() As WirelessAccessPoint()
Dim device As ManagementObject
Dim deviceName As String
Dim deviceOptions As New ObjectGetOptions
Dim devices() As String
Dim waps() As wirelessAccessPoint
Try
' get wap device names
Dim deviceClass As New ManagementClass("root/WMI",
"MSNDis_80211_BSSIList", deviceOptions)
For Each device In deviceClass.GetInstances
deviceName = device.GetPropertyValue("InstanceName").ToString()
If Not deviceName.ToLower.EndsWith("miniport") Then
Dim index As Integer = 0
If Not devices Is Nothing Then index = devices.Length
ReDim Preserve devices(index)
devices(index) = deviceName
End If
Next
If Not devices Is Nothing Then
' force a rescan of available waps
Dim scanClass As New ManagementClass("root/WMI",
"MSNDis_80211_BssIdListScan", deviceOptions)
Dim scanObject As ManagementObject = scanClass.CreateInstance()
For Each deviceName In devices
scanObject("Active") = True
scanObject("InstanceName") = deviceName
scanObject("UnusedParameter") = 1
scanObject.Put()
'now, get signal strength
Dim sql As String = "SELECT * " &
vbCrLf & _
"FROM MSNDis_80211_BSSIList " &
vbCrLf & _
"WHERE Active = 'TRUE' " &
vbCrLf & _
"AND InstanceName = '" & deviceName
& "'"
Dim query As New ManagementObjectSearcher("root/WMI", sql)
Dim wap As ManagementBaseObject
Dim wapCollection As ManagementObjectCollection = query.Get()
Dim wapEnumerator As
ManagementObjectCollection.ManagementObjectEnumerator =
wapCollection.GetEnumerator
wapEnumerator.MoveNext()
For Each wap In
wapEnumerator.Current.Properties("Ndis80211BSSIList").Value
Dim wirelessAccessPoint As New wirelessAccessPoint
With wirelessAccessPoint
.NetworkCard = deviceName
.SignalStrength =
CType(wap.GetPropertyValue("Ndis80211Rssi").ToString, Long)
.SSID = New
String(Encoding.ASCII.GetChars(CType(wap.GetPropertyValue("Ndis80211Ssid"),
Byte()))).Trim
End With
Dim index As Integer = 0
If Not waps Is Nothing Then index = waps.Length
ReDim Preserve waps(index)
waps(index) = wirelessAccessPoint
Next
Next
End If
Return waps
Finally
End Try
Return Nothing
End Function

#End Region

End Class


 
Reply With Quote
 
 
 
 
billy
Guest
Posts: n/a
 
      10th Nov 2005
| test console. it works however, both this code and in the wmi test console
| it appears i'm getting two rssi signals from the same wifi nic...the first
| has the "instancename" of the nic driver...the second is just a "?"...each
| have differing signal strengths. can someone explain?

yes...i can...ur a dumbass. it returns the name of the waps detected by your
nic and NOT the name of your nic driver. the more appropriate question to
ask would be: to which of these signals am i connected, if any?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WMI: SSID, RSSI & MAC address Spartakus Windows XP WMI 3 14th Dec 2008 05:20 PM
Get RSSI of wifi rbpkirow Windows XP WMI 0 1st Aug 2008 05:04 PM
How to find a relation between WMI NetworkAdapter and WMI Modem Joe Windows XP WMI 0 18th May 2006 10:20 AM
wap rssi billy Windows XP WMI 0 11th Nov 2005 07:18 AM
"Win32_Processor: WMI: Access denied" and "Win32_OperatingSystem: WMI: Access denied" Mark Jennings Windows XP WMI 3 29th Dec 2004 05:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:59 PM.