WLAN State

Discussion in 'Code Samples & Tips' started by mamuen, Aug 13, 2009.

  1. mamuen

    mamuen Member Licensed User

    Hi,

    this is my way to detect the Wlan-state. It works only on devices!
    Tested for WM5.0 and WM6.5
    .
    .
    .
    reg.New1
    reg.RootKey(reg.rtLocalMachine)
    .
    .
    x=getWlanState

    If x = 0 Then
    Msgbox(" no WlanCard!",cMsgboxOK,cMsgboxAsterisk)
    End If

    If x = 1 Then
    Msgbox(" Wlan is disabled!",cMsgboxOK,cMsgboxAsterisk)
    End If

    If x = 19 Then
    Msgbox(" Wlan is OK!",cMsgboxOK,cMsgboxAsterisk)
    End If
    .
    .
    .

    Sub getWlanState
    'HKEY_LOCAL_MACHINE\System\State\Hardware\Wifi (0 not present, 1 disabled, 19 enabled)
    wlan=0
    If cPPC Then
    regnames() = reg.GetValueNames("System\State\Hardware\")
    For i = 0 To ArrayLen(regnames())-1 'Show all values found
    If regnames(i)="Wifi" Then
    wlan = reg.GetValue("System\State\Hardware\", "Wifi")
    End If
    Next
    End If
    return wlan
    End Sub
     
  2. ghale

    ghale Active Member Licensed User

    Very good!

    Thanks!
     
  3. taximania

    taximania Well-Known Member Licensed User

    Just for the record.

    x=23 for 'Wlan is on', on my WM6.1 Pro O2-XDA Orbit
     
  4. agraham

    agraham Expert Licensed User

    From Googling around

    > 0 - powered off
    > 1 or 5 - ready
    > 11 or 15 - connecting
    > 19 or 23 - connected

    There was a suggestion that the offset of 4 might indicate ActiveSync is connected (or then again it might not!).

    Also you should be able to get the following system state notifications from my SystemState library.

    WiFiStateConnected
    WiFiStateConnecting
    WiFiStateHardwarePresent
    WiFiStateNetworksAvailable
    WiFiStatePowerOn
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice