[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Detect Internet DialUp connections

Posted on 1998-11-27
8
Medium Priority
?
181 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
  • 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
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.

 
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

831 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