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

后端 未结 5 1937
梦毁少年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条回答
  • 2021-01-02 13:42

    You can simply hide the installer wizard form by calling

    WizardForm.Hide;
    Exec(...);
    WizardForm.Show;
    

    though I agree that this is not really pretty.

    0 讨论(0)
  • 2021-01-02 13:42

    It's been 5 years since you've asked the question but here is my answer anyway.

    Before calling Exec() you can set the message that will be shown by Inno Setup above the main progress bar like this:

    WizardForm.StatusLabel.Caption := 'Installing .NET Framework 3.5. Please wait, this can take up to 1 hour...';
    
    0 讨论(0)
  • 2021-01-02 13:49

    We've needed to install .NET with a couple products, and have taken two approaches:

    • When installing .NET with Innosetup, we let the user know that the installation will take a long time, and to expect a certain message when it is complete
    • We start the .NET set up without any flags to force the client through it. This way if they're more technically inclined they know why the install is taking so long

    We've honestly had better luck with the 2nd option, particularly now that more system admins seem to lock down desktops to a certain degree.

    0 讨论(0)
  • 2021-01-02 14:06

    Although it probably would be easy, I don't recommend hiding your installer while the .Net installer runs. I've seen other installers do that, and when it happens, I think the installation is finished, and then I'm confused when I find that it's really not. (And when the installation really is finished, I can't be sure of that, either. Maybe it just hid itself again.)

    You can display custom pages in the Inno Setup wizard. Making such a page show a progress bar and keeping it accurate would probably be a challenge, but at least you could display a message on the wizard page saying that your installer is waiting for the .Net installer before proceeding. See the "Using Custom Wizard Pages" section of the help file.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题