Solved

Detection Dial up or Lan

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 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