Solved

Detection Dial up or Lan

Posted on 2001-08-04
4
178 Views
Last Modified: 2010-04-06
I need some help here. I wrote a program that uses FPiettes Ping (looking for internetconnection) and SMTP component (email some data to a user).

The problem : All of the above works fine on a computer with a constant internet connection using lan/cable, but there _can_ be users with a dial-up connection! So I have to find out if they have a lan/cable or dialup connection and if they do have a dialup I need to pop-up the dialup window.., but how?

I am looking for an answer all day now so please help me out.
0
Comment
Question by:DerkEimers
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 60 total points
ID: 6351288
Hello


  this procedure will determine the connetion type:
 
uses wininet;

Function ConnectionKind :boolean;
var
  flags: dword;
begin
  Result := InternetGetConnectedState(@flags, 0);
  if Result then
  begin
    if (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM then
    begin
      showmessage('Modem');
    end;
    if (flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN then
    begin
      showmessage('LAN');
    end;
    if (flags and INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY then
    begin
      showmessage('Proxy');
    end;
    if (flags and INTERNET_CONNECTION_MODEM_BUSY)=INTERNET_CONNECTION_MODEM_BUSY then
    begin
      showmessage('Modem Busy');
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ConnectionKind;
end;

//==========
And this one to dial up the default connection


Uses Registry, windows;

Function DUNDialDefault(Hide : Boolean) : Boolean;
// Show or hide the dial-up dialog
var Reg : TRegistry;
var TempResult : Boolean;
var Name, con : String;
var ASW : Integer;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('\RemoteAccess', False) then
  begin
    TempResult := True;
    Name := Reg.ReadString('Default');
  end
else begin
tempresult := False;
end;
Reg.Free;
if TempResult = True then
  begin
    if Hide = True then ASW := SW_HIDE
    else ASW := SW_SHOWDEFAULT;
    con := 'rnaui.dll,RnaDial ' + Name;
    ShellExecute(0, nil, 'rundll32.exe' , PChar
                  (con), 'C:\windows\', ASW);
end;
Result := tempResult;
end;

I got them from delphi3000:
http://www.delphi3000.com/articles/article_1031.asp
http://www.delphi3000.com/articles/article_1729.asp

Best regards
Mohammed Nasman
0
 

Author Comment

by:DerkEimers
ID: 6351593
I am not happy with the registry solution and how about Windows NT4? That's not going to work...
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6351656
listening... :-)
0
 

Author Comment

by:DerkEimers
ID: 6352017
It's a correct answer.. And I'm a fair guy...
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

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 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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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