Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detect a Broadband connection

Posted on 2004-03-22
6
Medium Priority
?
307 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 750 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

927 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