views:

712

answers:

3

Is there any way in Win32 to programmatically determine the bandwidth of a given network interface without actually transferring any data? I only want to distinguish between different types of interface (e.g. dialup vs DSL vs LAN), so a rough order of magnitude is fine, I don't need to actually measure the bandwidth.

Background to the problem is that my application is very bandwidth-hungry, and I want to display a warning to the user if they try and run it over a low-bandwidth interface, e.g. dialup modem or GPRS modem.

I've looked at some other related questions but if possible I'd like to avoid measuring throughput. GPRS modems in particular may have usage caps and I don't want to eat into a user's allowance - I'd rather detect the poor connection some other way and not actually send any data at all.

I'm most interested in Win32/C++ answers, but any ideas would be gratefully received.

+2  A: 

Why not asking the user? He should know.

Your app could cache the information for the network address and only ask again if the network address has changed.

lothar
I think this is a good solution.
BobbyShaftoe
@BobbyShaftoe feel free to upvote it ;-)
lothar
This is likely going to be my fallback option if there's no automatic way to achieve this.
snowcrash09
+1  A: 

You can use InternetGetConnectedState to determine the type of connection (LAN/Modem/etc). This will tell you if they have a somewhat decent (non-modem) connection without bandwidth transfer.

Unfortunately, you can't really go much beyond that without connecting and transferring data. There is no way for the system to know the bandwidth limitations outside of it's LAN connection - ie: you could connect to your gateway on a LAN directly, and it may have a crappy connection to the outside world. As far as your computer would be concerned, though, it's on a full speed lan connection...

Reed Copsey
InternetGetConnectedState is a good suggestion - thanks. I'm willing to take the risk of crap onward connections, all I want is a best efforts solution anyway.
snowcrash09
+2  A: 

You could use a WMI query, there are of course Win32 functions calls as well, but this query:

Select * from Win32_PerfFormattedData_Tcpip_NetworkInterface
BobbyShaftoe