Below is the code i`m using right now to start a process. What i`ll like is to find out how the process is terminated. It will be great if there is a way to get the exit code in the app_endEvent() procedure.
(a general function used to start applications)
Code: Select all
function app_run(const exeFile, sParam: string; endEventProc: cardinal = 0): Boolean;
var
mP: IProcess;
begin
Result := False;
mP := NewProcess( exeFile, sParam );
mP.PriorityClass := pcBelowNormal;
if endEventProc <> 0 then
mP.Notify(MsgHandlerWindow, endEventProc);
if mP.IsValid and mP.IsStillRunning then
Result := True;
end;
Code: Select all
procedure Tfrm_runApp.app_endEvent(window, msg: cardinal; wParam, lParam: integer; var result: integer);
var xCode: integer;
begin
if mP.IsStillValid then begin
xCode := mP.ExitCode;
_log('exitCode - ' + intToStr(xCode));
end;
_log('aplication terminated');
end;
Code: Select all
mP := app_run( ed_exeFile.Text, '', AddMsgHandler(app_endEvent) );
thank you