1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
procedure run_child_prog(path,name2 : string);
Var Fin : Boolean;
StartInfo : Windows.TStartupInfo;
ProcessInfo : Windows.TProcessInformation;
begin
// with form1 do
begin
FillChar(StartInfo,SizeOf(StartInfo),#0);
StartInfo.cb := SizeOf(StartInfo);
path:=path + '\' + name2 + #0; // + #0 car @path[1] est interpretté comme Pchar
if Windows.CreateProcess(nil, @path[1],nil, nil, False,
0, nil, nil, StartInfo,ProcessInfo) then
begin
Fin:=False;
repeat { On attend la fin de l'application }
case WaitForSingleObject(ProcessInfo.hProcess, 200)Of
WAIT_OBJECT_0 : Fin:=True; { L'application est termine, on sort }
WAIT_TIMEOUT :; { elle n'est pas termine, on continue d'attendre }
end;
{ Mise
jour de la fenêtre pour que l'application ne paraisse pas bloque. }
forms.Application.ProcessMessages
until Fin;
{ C'est fini }
end
else
showmessage('Problème au départ de ' + path + '\' + name2 +
' Il n''a pas été possible de démarrer l''application);
end;
end; |
Partager