wmi and rssi wap question

Discussion in 'Microsoft VB .NET' started by billy, Nov 10, 2005.

  1. billy

    billy Guest

    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
     
    billy, Nov 10, 2005
    #1
    1. Advertisements

  2. billy

    billy Guest

    | 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?
     
    billy, Nov 10, 2005
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. steve

    wap signal strength

    steve, Sep 14, 2004, in forum: Microsoft VB .NET
    Replies:
    13
    Views:
    296
    Cor Ligthert
    Sep 15, 2004
  2. BadMotherfucker

    WMI question

    BadMotherfucker, Nov 2, 2004, in forum: Microsoft VB .NET
    Replies:
    3
    Views:
    143
    One Handed Man \( OHM - Terry Burns \)
    Nov 2, 2004
  3. Jm

    WMI question

    Jm, Dec 9, 2004, in forum: Microsoft VB .NET
    Replies:
    2
    Views:
    119
    Herfried K. Wagner [MVP]
    Dec 9, 2004
  4. JTE

    WMI question

    JTE, Nov 25, 2006, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    158
  5. Spam Catcher

    .NET & WMI & SNMP -> Writing Values to WMI

    Spam Catcher, Dec 17, 2006, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    237
    Spam Catcher
    Dec 17, 2006
Loading...

Share This Page