Detecting a 3G connection in Windows 7 and 8 in a desktop application

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
I am in the process of developing a cloud backup software. The application is a desktop application developed using C#.
I need to add an option to stop/pause the backup if the computer was connected to a 3G network to save cost for the user.
I cannot seem to be able to find any example on how this can be achieved, there are some examples for Windows Phone and Windows Store Apps but I cannot find anything that can check if the connection type is a WiFi/Ethernet or
3G the latter is my main concern.

<p style="padding-right:0px; font-size:13.63636302947998px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; line-height:17.27272605895996px
I tried a test application to enumerate the networks:
<pre class="lang-cs prettyprint prettyprinted" style="padding:5px; border:0px; font-size:13.63636302947998px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; width:auto; max-height:600px; line-height:17.27272605895996px <code style="margin:0px; padding:0px; border:0px; font-size:13.63636302947998px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "checking network interfacesn"<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent

<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af NetworkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 []<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent interfaces <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af NetworkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af GetAllNetworkInterfaces<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent

<span class="kwd" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#00008b foreach<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="kwd" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#00008b var<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface <span class="kwd" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#00008b in<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent interfaces<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 )<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 {<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "Interface Detected"<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "Description: "<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 +<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Description<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "ID: "<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 +<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Id<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "Name: "<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 +<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Name<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "Interface Type: "<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 +<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af NetworkInterfaceType<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "Operational Status: "<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 +<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af OperationalStatus<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af ToString<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 ());<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "Speed: "<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 +<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Speed<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af ToString<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 ());<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "Supports Multicast: "<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 +<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent networkInterface<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af SupportsMulticast<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af ToString<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 ());<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Console<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af WriteLine<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="str" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 "#########################################################n"<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 );<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 }[/code][/code]
<p style="padding-right:0px; font-size:13.63636302947998px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; line-height:17.27272605895996px
The above code list my 3G connection as PPP which can be either ADSL or 3G. I am not sure if I can differentiate using some other options or APIs.
I need a clear way to distinguish between those networks and so far I cannot find a way of doing so.
Can someone please help?
<br/>

View the full article
 
Back
Top