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}
--