Click here to get back home

How to get connection type?

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
How to get connection type? Sven Rutten 06-09-2007
Get Chitika Premium
Posted by Sven Rutten on June 9, 2007, 4:26 am
Please log in for more thread options
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


Posted by Christian Resma Helle on June 9, 2007, 7:29 am
Please log in for more thread options
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


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
>


Similar ThreadsPosted
What connection type Connection Manager chose? December 19, 2006, 8:21 am
FILETIME type to String type August 10, 2005, 6:24 am
Connection Manager and Connection Flags August 24, 2005, 10:00 pm
Network type July 25, 2006, 2:36 am
Detecting Network Type August 11, 2005, 1:50 pm
How to use asyncrhonous API in console-type exe February 28, 2006, 1:27 pm
Type Load Exception February 26, 2007, 12:20 pm
oma dm wbxml content type June 18, 2007, 9:23 am
oma dm wbxml content type June 18, 2007, 9:25 am
How to check the type of device/browser? January 17, 2006, 2:54 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap