Determining internet connection type/speed with Delphi

davisa
davisa used Ask the Experts™
on
The basic function I'm trying to perform is to determine whether or not a user's Internet connection may be via a modem (or similarly slow device) or not, without going to the trouble of trying to download a file and determine transfer rate.  My plan was to do so by checking the hardware speeds of any connected/active network interfaces; modems won't be higher than 115200bps, while network cards will be 10Mbps or higher.  It's imperfect, given that I can't determine which interface will actually be used to access the Internet, but adequate and theoretically easy.

I had planned to use the function GetIfTable in IPHLPAPI.DLL, as that looked like it would do everything I need; however, it appears that that API doesn't consider a modem to be a network interface, and as such it doesn't return any information on modems in the system.

So, can anyone shed some light on how I might do this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012
Commented:
>>or suggest an alternate method of doing things?

What about

DWORD dwFlags = 0;
InternetGetConnectedState ( &dwFlags, NULL);

if ( dwFlags & INTERNET_CONNECTION_MODEM) {

 // modem connection
}

if ( dwFlags & INTERNET_CONNECTION_LAN) {

 // LAN connection
}

?
jkr
Top Expert 2012

Commented:
Ooops, missed the Delphi part, but the idea should be clear...

Author

Commented:
I wasn't aware of that particular function; that's what I get for being a Windows API novice, I guess.  I'll test that out now, and accept your comment if it works.  Thanks!

This works out well, too, since I just found out that GetIfTable doesn't seem to return anything about modems anyway.

Author

Commented:
Works perfectly for my purposes.  Thanks again!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial