Solved

Detection Dial up or Lan

Posted on 2001-08-04
4
177 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Machine not responding during CopyFile() 3 89
Communication Between RC4 Delphi <-> PHP 3 100
Strange behavior when a form is closed 6 51
Base1 Encode/Decode 3 68
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…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now