在Inno Setup中,ewWaitUntilIdle的精确定义是什么?

时间:2012-07-12 00:11:58

标签: inno-setup

作为安装程序的一部分,我需要调用DBMS系统并将其关闭,然后再启动它。如果该DBMS由于某种原因挂起,我的安装程序将永远挂起。我将Exec调用一个启动或停止数据库的命令,我的问题是:

ewWaitUntilIdle的定义究竟是什么?如果我的命令启动/停止数据库永远不会回来,那么什么符合空闲状态?

1 个答案:

答案 0 :(得分:1)

这是Inno的资料中的确切代码:

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;

如您所见,ewWaitUntilIdle只使用 WaitForInputIdle 功能 - 请点击此处:http://msdn.microsoft.com/en-us/library/windows/desktop/ms687022%28v=vs.85%29.aspx