Solved

Detect Internet DialUp connections

Posted on 1998-11-27
8
177 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 50 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
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!

 
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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

696 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