Get the modem to connect with a ISP.

I have D4  standard edition and Win98. I can use a safe call to bring up most any xxxx.exe. I can write instructions similar to:

procedure TForm1.Button1Click(Sender: TObject);
var
Str1,Str2,Totalcmdline:string;
c:char;
 begin
  Str1:='C:\program Files\Netscape\Communicator\program\netscape.exe';
  Str2:='http://tycho.usno.navy.mil';
  Totalcmdline := str1+' "' + str2+' "';
  Cprocess(Totalcmdline,Self);
end;

procedure TForm1.Cprocess(sExecuteFile:string;Sender: TObject);
var
 pi: TProcessInformation;
 si: TStartupInfo;
begin
  FillMemory(@si, sizeof(si),0);
  si.cb:=sizeof(si);
  CreateProcess(Nil,PChar(sExecuteFile),nil, nil, false, NORMAL_PRIORITY_CLASS, Nil, Nil,si,pi );
  // close up shop...
   closeHandle(pi.hProcess);
   closeHandle(pi.hThread);
end;

I would like bring up my modem to call  my ISP. If I use for Str1 in the above program as  Str1 := 'MyComputer\Dial-Up Networking\MyModemConnection.exe';
However, this does not work. So what should I use instead to cause the modem to dial the ISP?

Delphi3
LVL 4
delphi3Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

simonetCommented:
You can (and should) handle the RAS connection yourself.

The DialUp Networking is all based on top of an API called RAS  = Remote Access System.

I have just uploaded 2 great demos (with full source codes) to my site so you can download them and see how to do it. Here you go:

http://www.bhnet.com.br/~simonet/extras/dialup_demo.zip
http://www.bhnet.com.br/~simonet/extras/dialup_ras.zip

Both will show you how to directly manipulate the DialUp connections (create/modify/delete/use) directly from your Delphi application.

Yours,

Alex
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
delphi3Author Commented:
Hi Alex
This SafeCAll unit will show the solution in addition to the revision in RAS Test noted below that.

unit SafeCallNoFormUnit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  HarmFade;

type
  TForm1 = class(TForm)
    HarmFade1: THarmFade;
    procedure FormCreate(Sender: TObject);
    procedure HarmFade1MouseEnter(Sender: TObject);
  private
  procedure Cprocess(sExecuteFile:string;Sender: TObject);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
// using this as a way to launch the program

procedure TForm1.FormCreate(Sender: TObject);
var
Str1,Str2,Str3,Totalcmdline:string;
 begin

  //Ras PhoneDialer
  Str1:='C:\WINDOWS\Desktop\WorkFolder\DURas\RasTest.exe';
  Totalcmdline := str1+' "';
  Cprocess(Totalcmdline,Self);

  //Custom RAS phone timer keeps track of the time used while on internet
  Str2:='C:\WINDOWS\Desktop\WorkFolder\DUS#3\DialUpSpy.exe';
   Totalcmdline := str2+' "';
  Cprocess(Totalcmdline,Self);

  //MS Outlook Express

  Str3:='C:\Program Files\Outlook Express\Msimn.exe';
  Totalcmdline := str3+' "';
  Cprocess(Totalcmdline,Self);
end;

procedure TForm1.Cprocess(sExecuteFile:string;Sender: TObject);
var
 pi: TProcessInformation;
 si: TStartupInfo;
begin
  FillMemory(@si, sizeof(si),0);
  si.cb:=sizeof(si);
  CreateProcess(Nil,PChar(sExecuteFile),nil, nil, false, NORMAL_PRIORITY_CLASS, Nil, Nil,si,pi );
  // close up shop...
   closeHandle(pi.hProcess);
   closeHandle(pi.hThread);
end;

// slide the mouse over this small rectangular
// form  that has no caption bar   will activate program closing

procedure TForm1.HarmFade1MouseEnter(Sender: TObject);
begin
Application.Terminate;
end;

end.
// form1 as text
object Form1: TForm1
  Left = 712
  Top = 330
  BorderIcons = []
  BorderStyle = bsNone
  Caption = 'Form1'
  ClientHeight = 41
  ClientWidth = 105
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object HarmFade1: THarmFade
    Left = 0
    Top = 0
    Width = 105
    Height = 41
    OnMouseEnter = HarmFade1MouseEnter
    ColorFrom = clBlue
  end
end


And this is the  addition to dialup ras  program from Alex above

procedure TfrmTest.FormCreate(Sender: TObject);
begin
  btnGetEntriesClick(Self);
  btnGetParamsClick(Self);
  btnDialEntryClick(Self);
end;

Delphi3
0
delphi3Author Commented:
oops,

I reread the name of the unit that I named it above at first. It should have read

unit SafeCallNoCaptionUnit1;

because later  that is what was the final outcome.

Delphi3
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.