Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting connection speed...

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
0
0
I've come across an interresting little problem... I need to find the speed of the current internet connection (in bps, of course) if the user is connected. I have the connected, not connected part down, but the speed thing is the one that's getting me. Anyone have any ideas on how to go about getting the connection speed??

Thanks, Cyprus
[noevil]
 
Well, if Your'e in charge of the communication with the modem (dial-up and such) You get an answer in the form "CONNECT 44000" and there You got it but if Your'e using a driver You'd better hope the driver can answer to question. Best of luck.
 
how do i use this, i cant find any docs on it? Cyprus
 
The only documentation I could find is this link:

It looks like the function was intended for Windows CE but the VB program runs on WinNT4.

I did not find time to do it myself but when you try to port it to cbuilder, remember to include iphlpapi.h and iphlpapi.lib in the project.
 
It was not too difficult:

#include <stdio.h>
#include <iphlpapi.h>
void __fastcall TForm1::Button1Click(TObject *Sender) {
MIB_IFTABLE *t;
char buf[256];
DWORD s = 0;
if( GetIfTable( 0, &s, 0 ) == ERROR_NOT_SUPPORTED ) {
MessageBox( 0,&quot;IP Helper is not supported by this system.&quot;,&quot;ERROR&quot;,0);
return;
}
t = (MIB_IFTABLE *)malloc( s * sizeof(MIB_IFROW) );
if( GetIfTable( t, &s, 0) == ERROR_SUCCESS ) {
for( int i=0; i<t->dwNumEntries; i++ ) {
sprintf(buf,&quot;%s - %ld&quot;,t.table->bDescr,t.table->dwSpeed );
MessageBox( 0,buf ,&quot;debug&quot;,0);
}
} else {
MessageBox(0,&quot;FAILURE: GetIfTable( r, &s, 0)&quot;,&quot;debug&quot;,0);
}
free(t);
}

I hope it works on a dial-up adaptor, I could not test it in the office, modems are not allowed here.
 
When i try to execute the code its giving me a linker error saying unresolved external with &quot;GetIfTable&quot; referenced from $(BCB)\bin\unit1.obj...
I deleteed unit1.obj only to find a new one made and the same error. anything? Cyprus
 
Are you sure that iphlpapi.lib is included in your project ?
 
oh yea... sorry, lack of sleep comes hand in hand with lack of thought. Although it's quite apparent that my lack of thought comes hand in hand with just about everything.

I got the code working but it tells me this:
&quot;CP Loopback interface - 0&quot;

Which gives me no information on the speed of the connection. I'm not on a dialup, so that can't be the problem. Anything on this one? Cyprus
 
ok, just joking about the interface thing... but the nombers of the connection speed given are 1000000... this is definately NOT right. so now what? Cyprus
 
I could find this functions for connection config or etc. Please refer to these functions in rundll32 related library.

Call functions from Rundll always like that:

WinExec(&quot;rundll32 ...'&quot;,SW_SHOWNORMAL);
where rundll32... should be replaced by one of the functions below.

* Call a Connection with a configured Connection:
rundll32.exe rnaui.dll,RnaDial Internetzugang

* Show Properties for Modems:
rundll32.exe shell32.dll,Control_RunDLL modem.cpl

* Call Assistants to configure a Modem:
rundll32.exe shell32.dll,Control_RunDLL modem.cpl,,add

* Show the Network configuration:
rundll32.exe shell32.dll,Control_RunDLL netcpl.cpl

maybe there are some documents for thses functions in Borland C++ help. Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top