This is exact code from Inno's sources:
procedure HandleProcessWait(ProcessHandle: THandle; const Wait: TExecWait;
const ProcessMessagesProc: TProcedure; var ResultCode: Integer);
begin
try
if Wait = ewWaitUntilIdle then begin
repeat
ProcessMessagesProc;
until WaitForInputIdle(ProcessHandle, 50) <> WAIT_TIMEOUT;
end;
if Wait = ewWaitUntilTerminated then begin
{ Wait until the process returns, but still process any messages that
arrive. }
repeat
{ Process any pending messages first because MsgWaitForMultipleObjects
(called below) only returns when *new* messages arrive }
ProcessMessagesProc;
until MsgWaitForMultipleObjects(1, ProcessHandle, False, INFINITE, QS_ALLINPUT) <> WAIT_OBJECT_0+1;
{ Process messages once more in case MsgWaitForMultipleObjects saw the
process terminate and new messages arrive simultaneously. (Can't leave
unprocessed messages waiting, or a subsequent call to WaitMessage
won't see them.) }
ProcessMessagesProc;
end;
{ Get the exit code. Will be set to STILL_ACTIVE if not yet available }
if not GetExitCodeProcess(ProcessHandle, DWORD(ResultCode)) then
ResultCode := -1; { just in case }
finally
CloseHandle(ProcessHandle);
end;
end;
As you can see ewWaitUntilIdle simply uses WaitForInputIdle function - see more here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms687022%28v=vs.85%29.aspx