Solved

Detect a Broadband connection

Posted on 2004-03-22
6
299 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now