How do you make Inno Setup not look frozen while performing a long Exec?

后端 未结 5 1966
梦毁少年i
梦毁少年i 2021-01-02 13:28

The long Exec is installing .NET 3.5, and out script is based off this one: http://www.blackhillsoftware.com/blog/2006/06/26/using-innosetup-with-the-dotnet-fra

5条回答
  •  萌比男神i
    2021-01-02 14:07

    One way of making Inno Setup "not look frozen" is to add a "fake" progress indicator, like a marquee, to show that something is going on. But this won't solve the "window not dragable / moveable" problem.

    So, another way is to really unfreeze the Inno Setup GUI, while a long running process is executed: The "long running process" is executed via ShellExecuteEx(). Then the installer uses a while loop with the condition WaitForSingleObject and a very minimal timeout to execute AppProcessMessage.

    AppProcessMessage is itself a helper function. It uses "generic" code to recreate a Application.ProcessMessages-ish procedure, using the WinAPI function PeekMessage(), TranslateMessage() and DispatchMessage(). Its job is to be the message pump to the Inno Setup GUI.

    This trick makes the window responsive/draggable again, while the "long running process" is processed in the background.

    This is the source for the execution loop:

    if ShellExecuteEx(ExecInfo) then
    begin
      while WaitForSingleObject(ExecInfo.hProcess, 100) = WAIT_TIMEOUT
      do begin
          AppProcessMessage;
          WizardForm.Refresh();
      end;
      CloseHandle(ExecInfo.hProcess);
    end;
    

    The following GIST for unzip.iss contains the code for a standalone Unzip Helper for executing 7zip without blocking the Inno Setup GUI, including the bits and pieces for working with the AppProcessMessage function.

    In this case "unzip" is just an example and you might replace the executed application with whatever, a .NET installer or any other long running task.

提交回复
热议问题