Solved

Detect a Broadband connection

Posted on 2004-03-22
6
302 Views
Last Modified: 2010-04-04
Hi,

I need a function that will do this:

if (user has a broadband connection) then showmessage('Broadband')

else if (user has a normal dial up connection) then showmessage('Dialup');
0
Comment
Question by:siwiher
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:concon
ID: 10648079
Hi siwiher,

here is an example code to detect internet connection. you could find out connection type by changing dwConnectionTypes variable value. this detects all kinds of connection.

uses
   WinInet;

function IsConnectedToInternet: Boolean;
var
  dwConnectionTypes: DWORD;
begin
  dwConnectionTypes :=
    INTERNET_CONNECTION_MODEM +
    INTERNET_CONNECTION_LAN +
    INTERNET_CONNECTION_PROXY;
  Result := InternetGetConnectedState(@dwConnectionTypes, 0);
end;

Regards.
0
 

Author Comment

by:siwiher
ID: 10648173
Concon >>

I'm a little inexperienced could you give me a working example which would
detect a broadband connection and dialup.

There's an extra 50 points in it for you if it works!
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 10650430
Here you have an example but dont forget for the points CONCON that has provided the function

Best Regards
Marcos.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,WinInet;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
function IsConnectedToInternet: Boolean;
var
  dwConnectionTypes: DWORD;
begin
  dwConnectionTypes :=
    INTERNET_CONNECTION_MODEM +
    INTERNET_CONNECTION_LAN +
    INTERNET_CONNECTION_PROXY;
  Result := InternetGetConnectedState(@dwConnectionTypes, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  if IsConnectedToInternet then
  ShowMessage('Conected')
  else
  ShowMessage('Not Conected');
  end;

end.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:siwiher
ID: 10651869
Sorry lads maybe i have not made myself clear - i can detect an internet connection

however I need my program to tell me what type it is - broadband or dialup

basically if the internet is always on I need to know about it

if the user uses a dialup then I need to make the distinction between the two!
0
 
LVL 3

Accepted Solution

by:
concon earned 250 total points
ID: 10655511
hi;

i have channged the procedure. maybe this helps.

// no connection returns 0
// dial-up returns 1
// broadband returns 2
function GetConnectionType: integer;
var
  dwConnectionTypes: DWORD;
begin
  dwConnectionTypes := INTERNET_CONNECTION_MODEM;
  if InternetGetConnectedState(@dwConnectionTypes, 0) then
     result := 1
  else
  begin
     dwConnectionTypes := INTERNET_CONNECTION_LAN + INTERNET_CONNECTION_PROXY;
     if InternetGetConnectedState(@dwConnectionTypes, 0) then
        result := 2
     else
        result := 0;
  end;
end;

regards.
0
 

Author Comment

by:siwiher
ID: 10655998
Thanks I'll try it when i get home
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question