el programa ejecuta otro exe y espera a que termine para realizar otra accion
Código: Seleccionar todo
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils,
windows,
SHELLAPI,
dialogs;
function runyespera(archivo,dir:string):bool;
var
shinfo:TShellExecuteInfo;
ExitCode:DWORD;
begin
ZeroMemory(@shinfo, SizeOf(shinfo));
shinfo.cbSize := sizeof(SHELLEXECUTEINFO);
shinfo.fMask := SEE_MASK_NOCLOSEPROCESS;
shinfo.lpFile := pchar(archivo);
shinfo.lpParameters :=nil;// en este caso no le paso parametros;
shinfo.lpDirectory := pchar(dir);
shinfo.nShow := SW_SHOW;
ShellExecuteEx(@shinfo);
repeat
ExitCode := WaitForSingleObject(SHInfo.hProcess,INFINITE);
until (ExitCode <> WAIT_TIMEOUT);
result:=true;
end;
begin
IF runyespera( 'mi archivo.exe','c:\windows\ejemplo')THEN
SHOWMESSAGE('SE TERMINO LA APLICACION PRINCIPAL');
// se puede realizar cualquier accion al terminar
//
end.