?
Solved

Detect Internet DialUp connections

Posted on 1998-11-27
8
Medium Priority
?
178 Views
Last Modified: 2010-04-04
Hi All,

I want to write a little application to detect internet dialup connections and launchs my application (like ICQ NetDetect). How can I do that?

Thanks in advance.
0
Comment
Question by:sergio_2001
[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
  • 4
  • 2
  • 2
8 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 150 total points
ID: 1348263
sergio_2001,

you can use something like below to check 'remote connection' key it changes when a ras connection is made.
to see what i mean run regedit and check HKEY_LOCAL_MACHINE\
System\CurrentControlSet\Services\RemoteAccess\remote connection  value then close regedit and connect to net
and reopen regedit and recheck you'll see value has changed.

Function GetRasStatus:Longint;   { get number of RAS onnections }var
MyRegistry:TRegistry;
begin         { Change registry to load every time }
MyRegistry:=TRegistry.Create;
With MyRegistry dobegin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('System\CurrentControlSet\Services\RemoteAccess',True);
ReadBinaryData('Remote Connection',Result,SizeOf(Result));
CloseKey;
end;
MyRegistry.Free;
end;
Function DetectConnection:Boolean;
var
IPList:TStrings;
begin
IPList:=LocalIPList;
Result:=IPList.Count<>0;
If GetRasStatus>0 then Result:=True;
end;

Barry,
0
 

Author Comment

by:sergio_2001
ID: 1348264
inthe,

Your  answer looks good. But I have some problems with the function:

Function DetectConnection:Boolean;
    var
    IPList:TStrings;
    begin
    IPList:=LocalIPList; {where is declared? or what I must include here?}
    Result:=IPList.Count<>0;
    If GetRasStatus>0 then Result:=True;
end;

The IPList:=LocalIPList; ?????

Waiting for comments...
thanks
0
 
LVL 17

Expert Comment

by:inthe
ID: 1348265
hi,
i'll post a full unit tonight gmt time
you dont have to use some of the lines just getting status of key in registry will do
Regards Barry

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!

 
LVL 17

Expert Comment

by:inthe
ID: 1348266
Hi Sergio
1 button on form with a onclick event

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
   
  public
   
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
Function GetRasStatus:Longint;
var
MyRegistry:TRegistry;
begin
MyRegistry:=TRegistry.Create;
With MyRegistry do begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('System\CurrentControlSet\Services\RemoteAccess',True);
ReadBinaryData('Remote Connection',Result,SizeOf(Result));
CloseKey;
end;
MyRegistry.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.text:=inttostr(getrasstatus);
end;

end.
 Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 1348267
sorry dude wrong one here is correct one:
unit Unit1;

interface

uses
  Windows, Messages,Registry,shellapi, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
  public
    end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
Function GetRasStatus:Longint;
var
MyRegistry:TRegistry;
begin
MyRegistry:=TRegistry.Create;
With MyRegistry do begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('System\CurrentControlSet\Services\RemoteAccess',True);
ReadBinaryData('Remote Connection',Result,SizeOf(Result));
CloseKey;
end;
MyRegistry.Free;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
if  getrasstatus = 1
then
ShellExecute(Handle, NIL, 'c:\windows\calc.exe', NIL, NIL, sw_ShowNormal)
else showmessage('not connected');
end;

end.
 
0
 

Author Comment

by:sergio_2001
ID: 1348268
Hi inthe,

I will evaluate your answer to grade you ASAP.

regards
0
 

Expert Comment

by:Mikkel_48
ID: 22583005
I have a very similar requirement to the original question. In my case I wish to keep a log of times and dates I am connected to the internet via my Dial-Up Connection The solution should work on Windows 2000 upwards to Vista and be compatible with Delphi.
I looked at the provided solution but in my Windows (XP, SP3) if I look at the registry key specified 'System\CurrentControlSet\Services\RemoteAccess', there is no binary data value ''Remote Connection'. Am I missing something or was that correct for Windows 98, but later versions don't have it?
Any comments from the solution provider (or the question poster)? I am happy to pose a new question if necessary.
0
 

Expert Comment

by:Mikkel_48
ID: 22583519
Addendum to my previous comment:
I would still like the solution providers comments on his solution and curent Windows compatibility but some searching has revealed many questions and solutions on this topic and it will take me some time to research and test them all. Therefore not going to post a new question yet.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

752 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