Test if WiFi is off/on in the Networks fly-out Win8.1 tab

Rogue

New Member
Messages
3
Hi

I am putting together an app in vb6 (not a .Net coder as yet) that needs WiFi some of the time but not often and to preserve battery I would like to tell the user if WiFi is on when it needn't be.

I found an excellent shortcut on this site that pops out the Networks fly-out pane (thanks for that!) but I would like to test if the WiFi switch is on or off.

I found some code elsewhere that uses a WMIService call to get the name of the WiFi adapter if it is connected. That works but it returns a null string if either the WiFi is off or it is On but no WiFi connection has been chosen so it doesn't give me quite what I need.

The code for getting the WiFi name is shown at the bottom of this message. I am thinking it is the wrong way to go as it relates to the adapter not the Windows switch but not sure.

I had considered using the Airplane mode on/off that I also found on this site but I am having trouble getting back to my app after it runs and I would prefer the user to control it themselves anyway (hence the flyout)

To see what changed I exported the registry on the device (HP Stream 7 running WIn 8.1) with WiFi switched on and then again having switched it off

I then compared the text files and I found a flag that sounds promising called RFOff (it is 1 when WiFi is off and 0 when on). Am guessing RF is Radio something

It is. however, deep in the CurrentControlSet001 under ....

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0000]

a couple of the values (there are many) are ...


"DriverDesc"="Realtek RTL8723BS Wireless LAN 802.11n SDIO Network Adapter"
"RFOff"=dword:00000000

Assuming I am right and that flag is the marker for the WiFi switch then how would I find it on any given machine (I have several to set up so assuming they wouldn't all have the same GUID for the WiFi device)



All I need to do is test for it, not intention of setting it. If WiFi is On then I can pop out the flyout pane

Any help gratefully received!

Thanks

Simon


Here is the code for detecting the WiFi name.

bIsWifiOn = False

On Error Resume Next
sComputer = "."
Set oWMIService = GetObject("winmgmts:" & sComputer & "\root\CIMV2")
Set colWifi = oWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID =" & "'" & sGetWirelessName & "'" & "and PhysicalAdapter='True' ")

Dim sSt As String
Dim sSi As String

If Not colWifi Is Nothing Then
For Each oWifi In colWifi
If oWifi.Netconnectionstatus = 2 Then
If Trim(oWifi.Name) <> "" Then bIsWifiOn = True
End If
Next
End If
 

My Computer

System One

  • OS
    Windows 8.1
Doesn't the Windows OS already do this from the Desktop aspect via the Notification Tray Icon on the Taskbar?

Then, it's all a matter of presenting that information discreetly in the Modern aspect. BTW, I've stayed away from the Modern aspect. Still, I don't think the presentation can be done, in a non-jarring way. I guess that's the challenge: find a way to intrude upon an app running full-screen to say, "Turn off the WiFi!"
 

My Computer

System One

  • OS
    win 8.1
    Computer type
    Laptop
Why recreate the wheel? This feature is already available in all editions of Windows.
 

My Computer

System One

  • OS
    Linux Mint 17.2
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satellite C850D-st3nx1
    CPU
    AMD E1-1200 APU with Radeon (tm) HD Graphics 1.40 GHZ
    Memory
    12GB
    Graphics Card(s)
    AMD Radeon™ HD 7310 Graphics
    Sound Card
    Realtek HD
    Monitor(s) Displays
    LCD
    Screen Resolution
    1366 x 768
    Hard Drives
    Crucial M500 240GB SSD
    Mouse
    Logitech M525
    Internet Speed
    45/6 - ATT U-Verse
    Browser
    Google Chrome
    Antivirus
    None needed. It is Linux.
    Other Info
    Arris NVG589 Gateway; Router - Cisco RV320; Switch - Netgear GS108 8-Port Switch & Trendnet TEG-S50g 5-Port Switch; Access Points - Engenius ECB350, Trendnet TEW-638APB; NAS - Lenovo ix2-4; Printer - Brother HL-2280DW; Air Print Server - Lantronix XPrintServer

    A/V UPS - Tripp-Lite Smart 1500LCD 1500 Va/900 W.
Hi

Thanks for your replies, sooner and broe.

sooner - It does show the status in the tray yes but my app is full screen (on the desktop) and the taskbar isn't visible. Not sure what the Modern aspect is, is that another term for the Metro interface? If so then I am not using that.

broe - I am not trying to recreate the wheel, I am not sure what feature you are referring to?

I want my app to know if WiFi is on or off so I can control what options the user has and if they are in a part of the app where WiFi isn't needed (and they will be in that bit for several hours) then I want the app to tell the user if WiFi is on to remind them to switch it off

Is there some way to tell if the Windows WiFi switch is on or off from the registry or something else I can test with VB

Thanks

Simon
 

My Computer

System One

  • OS
    Windows 8.1
Usually, when someone uses the term "app" or "application" as it relates to Windows 8, I associate it with the Modern/Metro side. "Programs" run in Desktop mode.

Back to the topic at hand, as broe23 and I try to say, the Windows OS already 'streams' that info, and presents it in the Notification Tray. Then, it's just a matter of finding that stream and tapping into it. That knowledge is way 'above my pay grade', as the saying goes.

Thinking outside the box, wouldn't it be better to have an option of running your 'app' in Desktop mode in a full-sized window? Then, the taskbar is always in view.

Or your 'app' opening splashscreen can offer a reminder to turn off the WiFi.
 

My Computer

System One

  • OS
    win 8.1
    Computer type
    Laptop
sooner - fair enough, was just being lazy with my terminology. It is a program. It runs in Desktop mode.

WiFi does appear in the system tray but my program when running full screen is over the top of the taskbar. Not sure why (prob cos it is VB6) but I don't really want to lose all the space the Taskbar takes up anyway just to show the one little icon that shows the WiFi setting. It is only a 7 inch tablet so space is quite tight.

Mainly I want to draw my user's attention to their WiFi setting and I can do that more obviously in the program.

They will need WiFi on when they start the program for a bit, then not for ages and then on again towards the end of the session.

I can rely on them to do as asked and switch it on/off but I wanted a way of checking that to give a reminder if it gets missed.

I want to give the battery life as long a run as possible and WiFi off is an easy way to help that

I can live with trusting them if I have to but what I want to do is detect the WiFi status. I was hoping someone knew a way. "Tapping into the stream" as you put it.

Am fairly sure the registry key I found is relevant but can't see how to find it on just any machine. Hoping there is something easier.
 

My Computer

System One

  • OS
    Windows 8.1
Back
Top