|
Posted by Sven Rutten on June 9, 2007, 8:54 am
Please log in for more thread options Thanks, this is exactly what I've been looking for
> You can use the State and Notification API in the Windows Mobile 5
> SDK.
>
> You can use the following properties:
>
> Microsoft.WindowsMobile.Status.SystemState.ConnectionsDesktopCount
> Microsoft.WindowsMobile.Status.SystemState.ConnectionsCellularCount
> Microsoft.WindowsMobile.Status.SystemState.ConnectionsNetworkCount
>
>
> you can also subscribe to SNAPI for the ones mentioned above.
>
> [C# CODE]
>
> // START OF CODE
> private SystemState wlan = null;
> private SystemState gprs = null;
> private SystemState activesync = null;
>
> public void Subscribe()
> {
> gprs = new SystemState(SystemProperty.ConnectionsCellularCount);
> gprs.Changed += new ChangeEventHandler(GPRS_Changed);
>
> activesync = new
> SystemState(SystemProperty.ConnectionsDesktopCount);
> activesync.Changed += new
> ChangeEventHandler(DesktopConnection_Changed);
>
> wlan = new SystemState(SystemProperty.ConnectionsNetworkCount);
> wlan.Changed += new ChangeEventHandler(WLAN_Changed);
> }
>
> void DesktopConnection_Changed(object sender, ChangeEventArgs args)
> {
> if (SystemState.ConnectionsDesktopCount > 0) {
> // DO YOUR STUFF
> }
> }
>
> void GPRS_Changed(object sender, ChangeEventArgs args)
> {
> if (SystemState.ConnectionsCellularCount > 0) {
> // DO YOUR STUFF
> }
> }
>
> void WLAN_Changed(object sender, ChangeEventArgs args)
> {
> if (SystemState.ConnectionsNetworkCount > 0) {
> // DO YOUR STUFF
> }
> }
> // END OF CODE
>
> I hope this helps
>
>
> Regards,
> Christian Resma Helle
>
|