views:

1205

answers:

6

I have an installation program (just a regular C++ MFC program, not Windows Installer based) that needs to set some registry values based on the type of Internet connection: broadband, dialup, and/or wireless. Right now this information is being determined by asking a series of yes or no questions. The problem is that the person doing the installations is not the same person that owns and uses the computer, so they're not always sure what the answers to these questions should be. Is there a way to programatically determine any of this information? The code is written in C++ (and optionally MFC) for Windows XP and up. .NET-based solutions are not an option because I don't want to have to determine if the framework is installed before our installation program can run.

To clarify, the issue is mainly that wireless and dialup connections are not "always-on", which creates a need for our product to behave a different way because our server is not always available. So a strictly speed-measuring solution wouldn't help, though there is a setting that's speed dependent so that the product doesn't try to send MB of information through a dialup connection as soon as it connects.

A: 

Best bet would be to grab the default active network connection, ensure it is an internet connection (ping google.com or similar) and then ask it what type of device it is. You should be able to determine from that what connection the user has.

I'm fairly confident this is possible, but not sure how to go about it though.

workmad3
I was trying to avoid having to keep a list of devices and their classes, since someone will always come up with one I haven't thought of, but I agree that it may turn out to be necessary.
jeffm
+2  A: 

[I have no idea how to get exactly the information you asked for, but...] Maybe you could rephrase (for yourself) what you try to accomplish? Like, instead of asking "does the user have broadband or dialup", ask "how much bandwidth does the user's internet connection have" - and then you can try to answer the rephrased question without any user input (like by measuring bandwidth).

Btw. if you ask the user just for "broadband or dialup", you might encounter some problems:

  • what if the user has some connection type you didn't anticipate?
  • what if the user doesn't know (because there's just an ethernet cable going to a PPPoE DSL modem/router)?
  • what if the user is connected through a series of connections (VPN via dialup, to some other network which has broadband?)

Asking for "capabilities" instead of "type" might be more useful in those cases.

oliver
Good point. See clarification above.
jeffm
A: 

I think you should just do a quick connection-speed test. Just download some specific sized files, time how long it takes, and you'll know the speed. I agree with the other guy, don't ask them what type of connection they have, what's more important is the speed. Perhaps next year they come out with 100mbit dialup...do you want everyone using this amazing new device to get the crappy lowbandwidth version of your app?

davr
A: 

Regarding the question "is the internet connection permanent or not?":

  • best way would be probably to make the app robust enough to always cope with a non-permanent connection :-) which would work the same with dialup and broadband...
  • alternatively, maybe you can find out how long the user's internet connection has been established already, and compare with system uptime? If the connection has been online for almost as long as the computer was running, it's probably a permanent connection.

Anyway, these heuristics will probably fail for obscure connection types.

Also, regarding the point about not sending lots of data: if people have a "broadband + low traffic limit" tariff, you shouldn't send lots of data either even if bandwidth allows :-)

Point taken about the design of the program coping with the connection type. There's a reason it's like that, but it's hard to explain without going into what the app does which I can't really do in public.
jeffm
A: 

I would agree with oliver, as you imply: you have the functionality already to cope with connection loss, why not enable it by default.

Broadband connections can get messed up to: routersoftware that freezes (happens a lot to me), or poweradapter that fries, ...

Emile Vrijdags
+1  A: 

use InternetGetConnectedState API to reterive internet connection state. I tested it and it works fine.

I found this document which can help:

http://www.pcausa.com/resources/InetActive.txt

Nacereddine