with SUI
dobegin cb:=Sizeof(SUI);
lpReserved:=Nil;
lpDesktop:=Nil;
lpTitle:=Nil;
dwX:=0;
dwY:=0;
dwXSize:=0;
dwYSize:=0;
dwXCountChars:=0; dwYCountChars:=0; dwFillAttribute:=0; dwFlags:=0; wShowWindow:=0; cbReserved2:=0; lpReserved2:=Nil; end;
Path1:=ExecPath;
Path2:=Path1+' '+Parameters;
// Arrancar el EmbConfig if CreateProcess(
PChar(Path1), //
pointer to name of executable module PChar(Path2), //
pointer to command line string Nil,
// pointer to process security attributes Nil,
// pointer to thread security attributes False,
// handle
inheritance flag CREATE_DEFAULT_ERROR_MODE,
// creation flags Nil,
// pointer to new environment block PChar(ExtractFilePath(Path1)), // pointer to current directory
name SUI,
// pointer to STARTUPINFO PIN
// pointer to PROCESS_INFORMATION ) thenbegin// Process is running Self.Enabled:=false; // I
Disable my own process, optional // Some people
prefer to use INFINITE, I wait 3 seconds and process my messages // as you
prefer While (WaitForSingleObjectEx(PIN.hProcess, 3, False)
= WAIT_TIMEOUT) do begin Application.ProcessMessages;
end; Self.Enabled:=True; // Enabled
my own process GetExitCodeProcess(PIN.hProcess,
ExitCode);
// ExitCode is the
process exit code, obvious If
ExitCode=0 thenbegin// 0 or any other value you want to check for // whatever end; end elsebegin// CreateProcess has
failed! // do as needed end; end;