Switch Wi-Fi on

D

Diamond

Hi,

I'm looking for a way to switch Wi-Fi on/off using .NET framework.

Can someone help me ?

Thanks
David
 
P

Peter Foot

There isn't a way exposed in the Compact Framework itself. We have a
WirelessManager class in our Mobile In The Hand product which can toggle
the three radio types on the device (Phone, WiFi and Bluetooth) -
http://inthehand.com/content/Mobile.aspx

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - Software Solutions for a Mobile World
In The Hand Ltd - .NET Components for Mobility
 
D

Diamond

I found it:
Public Class Wifi
<DllImport("coredll.dll")> _
Private Shared Function DevicePowerNotify(ByVal name As String, ByVal
state As CEDEVICE_POWER_STATE, ByVal flags As Integer) As Integer
End Function

Private Enum CEDEVICE_POWER_STATE As Integer
PwrDeviceUnspecified = -1
D0 = 0 ' Full On: full power, full functionality
D1 = 1 ' Low Power On: fully functional at low power/performance
D2 = 2 ' Standby: partially powered with automatic wake
D3 = 3 ' Sleep: partially powered with device initiated wake
D4 = 4 ' Off: unpowered
PwrDeviceMaximum = 5
End Enum

Public Shared Function EnableWifi() As Boolean
Return DevicePowerNotify("WLP1:", CEDEVICE_POWER_STATE.D0, 1) = 0
End Function 'EnableWifi


Public Shared Function DisableWifi() As Boolean
Return DevicePowerNotify("WLP1:", CEDEVICE_POWER_STATE.D4, 1) = 0
End Function 'DisableWifi
End Class 'Wifi
 
A

Achim Bohmann

Hi!

I was searching that feature for months. Now i hoped you found, but on
my WM6 this does not work...

where did you find these infos? maybe i can find there how to switch on
Wifi on WM5/6...

regards
Achim
 
P

Peter Foot

The problem with this approach is in many cases the names assigned to
specific drivers are different across different hardware. You could try
looking through the registry to find out what your wifi adapter is called.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - Software Solutions for a Mobile World
In The Hand Ltd - .NET Components for Mobility
 
A

Achim Bohmann

Hi Peter,

as there are commercial products solving that issue, there might be an
easier solution to do so, that always works...

i am still on the search, writing here again, when found.

regards
Achim
 
P

Paul G. Tobey [eMVP]

What, for example? There is no "turn wifi on" operation in the operating
system. You can be absolutely sure of that. In fact, other than by
querying the driver after it is loaded, the network stack does not know that
the device even *has* WiFi. You could, since you're asking in a .NET CF
group, enumerate all of the network adapters on the device (this has been a
previous topic of discussion which you can look for using GoogleGroups),
find those which are marked as WiFi, and then make sure that those are on or
off using other previously-discussed methods (search, again). However, if
an adapter uses its own configuration program, or if the device OEM has done
something like that, rather than using the Windows CE standard WZC stuff to
do the configuration, there's no way to distinguish between a wireless
adapter an a wired Ethernet adapter. There can be no "quick global
solution" to this. You either figure out what the right answer for your
specific device is and use that shortcut, or you do something very general,
but still have to live with the 1%or 2% of devices that do something that
you can't correct for.

Paul T.
 
P

Paul G. Tobey [eMVP]

Just note that this is Windows Mobile-specific, but nice information!
Thanks,

Paul T.
 

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