Answer the question
In order to leave comments, you need to log in
Why doesn't CreateProcess always work correctly?
The code in Delphi looks like this:
FillChar(StartUpInfo, SizeOf(TStartUpInfo), 0);
with StartUpInfo do begin
cb:= SizeOf(TStartUpInfo);
dwFlags:= STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow:= ShowCmd;
end;
CreateProcess(nil, PWideChar(JavaPath+' '+Parameters), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, MinecraftPath, StartUpInfo, ProcessInfo);
WaitForInputIdle(hProcess, INFINITE);
WaitforSingleObject(hProcess, INFINITE);
GetExitCodeProcess(hProcess, ExitCode);
CloseHandle(hThread);
CloseHandle(hProcess);
Answer the question
In order to leave comments, you need to log in
Good afternoon,
So everything stops at WaitforSingleObject(hProcess, INFINITE); after you have called the function for the first time. The second application will not start until the first one is completed.
As an addendum, try this function:
function ExecuteApplication(ACmd: string; AWaitForTerminate: boolean=false; AHideWindow: boolean = false): THandle;
var
si: STARTUPINFO;
pi: PROCESS_INFORMATION;
begin
Result:=0;
try
ZeroMemory(@si,sizeof(si));
si.cb:=SizeOf(si);
si.dwFlags := STARTF_USESHOWWINDOW;
if AHideWindow then si.wShowWindow := SW_HIDE else si.wShowWindow := SW_SHOW;
if not CreateProcess(nil, PChar(ACmd), nil, nil, False, 0, nil, nil, si, pi)
then begin
Exit;
end;
Result:=pi.hProcess;
if AWaitForTerminate
then begin
WaitForSingleObject(pi.hProcess, INFINITE );
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
end;
except
end;
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question