Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Detect a Broadband connection

Posted on 2004-03-22
6
Medium Priority
?
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

670 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