Launching 
Author Message
 Launching

Please I hope someone can help me out with launching other applications
from delphi applications. I can do it with the following code but any time
I pass in double quotes as required by the called application they get
stripped out.

Any idea on getting it to work? Here is an example of how I call the
application.

procedure TMainForm.DBUnloadButnClick(Sender: TObject);
 const
  kEXE_DBUnload = 'c:\sybase\adaptive server anywhere
                     6.0\win32\dbunload.exe';
  kCONNECT_55 = '"-c "dbf=d:\posim55\posim.db;uid=dba;pwd=mtdew"
                  -o d:\posim55\errlog.txt d:\posim55\unload"';
begin
 DM1.Launch(kEXE_DBUnload, kCONNECT_55);
end;

procedure TDM1.Launch (appStr, paramStr: String);
  var
    siStartInfo:TStartupInfo;
    piProcessInfo:TProcessInformation;
    b:boolean;
    flags:integer;
    directory: String;
    dwExitCode:DWord;
begin
  { --- create a process --- }

  siStartInfo.cb := SizeOf(siStartInfo);
  siStartInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
  siStartInfo.wShowWindow := SW_SHOWNORMAL;
  flags := NORMAL_PRIORITY_CLASS;
  directory := ExtractFileDir(appStr);
  if (directory = '') then
    directory := gApplDir;

(*
  b := CreateProcess(PChar(appStr),PChar(appStr+'
'+paramStr),nil,nil,false,flags,nil,PChar(directory),
  siStartInfo,piProcessInfo);
*)
  b := CreateProcess(nil,PChar(appStr+'
'+paramStr),nil,nil,false,flags,nil,PChar(directory),
  siStartInfo,piProcessInfo);

  if not b then
    MessageDlg('Sorry, the program "' + appStr + '" could not be
run.',mtError,[mbOK],0)
  else begin
    { --- wait for process to run --- }
    WaitForInputIdle(GetCurrentProcess,INFINITE);
    if piProcessInfo.hProcess <> 0 then begin
      dwExitCode := STILL_ACTIVE;
      while dwExitCode = STILL_ACTIVE do begin
        WaitForSingleObject(piProcessInfo.hProcess,1000);
        GetExitCodeProcess(piProcessInfo.hProcess,dwExitCode);
      end;
    end;
  end;
end; {TDM1.Launch}

--



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. HELP: Launching a Windows Application from Delphi v2.0

2. launch question

3. System Calls (Launching an App)

4. I need HELP launching applications

5. Launching Internet Explorer with a pre-determined file

6. HELP : Error launching Reportsmith

7. DBD error when launching

8. client access launch from delphi

9. Help: Launching ReportSmith run-time from Delphi application

10. launching an .EXE from pascal?

11. Opening/Launching Doc/File from ListView

12. BP hangs when launched from windows

 

 
Powered by phpBB® Forum Software