How to get connection type?

S

Sven Rutten

Hello

How can I get the type of a Internet Connection? (GPRS, UMTS, WLAN, USB) ?

I would like to know if it is either GPRS/UMTS (which does cost) or WLAN/USB
which is free...

In .NET

Thanks

Sven
 
C

Christian Resma Helle

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
 

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