Search code examples
c#compact-frameworkwifismart-device-framework

Monitoring WLAN Radio Connection in Windows Mobile 6/C#


I am currently developing an app targeted for the HP IPAQ 210. Part of this app requires the WLAN radio to be enabled/powered on to connect to a pre-configured access point. I'm currently using the IPAQ SDK (via P/Invoke) to enable the WLAN radio, but I'm having trouble reliably determining when the radio has established a connection with the preferred access point. I'm currently monitoring the Microsoft.WindowsMobile.Status.SystemState.WiFiStateConnected property, but I would prefer to subscribe to an event to be notified when the connection is established.

I've looked around a bit in the OpenNETCF library, and there seems to be promising things in 2.3, but we're stuck on 2.2 for the moment.

Is there a reliable way to determine the connection status?


Solution

  • It is ugly, and it is no event, but if all else fails, you could try and check the Wifi hardware state by reading it's registry key:

    int key = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\State\\Hardware", "WiFi", -1);