Use two/multiple selected directories from custom page in Files section

前端 未结 1 708
轻奢々
轻奢々 2020-12-03 19:54

I need create custom page of two destination.

I\'ve done:

#define MyAppName \"TESTPROG\"
[Setup]

AppName=         


        
相关标签:
1条回答
  • 2020-12-03 20:44

    Use a scripted constant:

    [Files]
    Source: C:\TEST\DLL1.bat; DestDir: "{code:GetDir|0}\sys1"
    Source: C:\TEST\DLL2.bat; DestDir: "{code:GetDir|1}\sys2"
    
    [Code]
    
    var
      Page: TInputDirWizardPage;
    
    function GetDir(Param: string): string;
    begin
      Result := Page.Values[StrToInt(Param)];
    end;
    
    procedure InitializeWizard;
    begin
      Page := CreateInputDirPage(...);
      ...
    end;
    

    If you want to use one of the (the first) paths from the TInputDirWizardPage instead of the path from "Select Destination Location" page, you have three options.

    1. Disable the "Select Destination Location" page using DisableDirPage directive:

      DisableDirPage=yes
      

      Copy the path from the TInputDirWizardPage to the hidden "Select Destination Location" page, when the user presses Next button:

      var
        Page: TInputDirWizardPage;
      
      function InputDirPageNextButtonClick(Sender: TWizardPage): Boolean;
      begin
        { Use the first path as the "destination path" }
        WizardForm.DirEdit.Text := Page.Values[0];
        Result := True;
      end;
      
      procedure InitializeWizard();
      begin
        Page := CreateInputDirPage(...);
        ...
        Page.OnNextButtonClick := @InputDirPageNextButtonClick;
      end;
      

      To complement that you may also consider copying the initial WizardForm.DirEdit to your custom box. This way you make sure that 1) on re-install/upgrade, the previously selected value is reused; 2) /DIR command-line switch works. For that see How to make Inno Setup /DIR command line switch work with custom path page.

    2. Replace all uses of the {app} constant with {code:GetDir|0}.

      Make Inno Setup not create the {app} path using CreateAppDir directive:

      CreateAppDir=no
      

      (this implies DisableDirPage=yes).

      And have the uninstall files be stored in the first path using UninstallFilesDir directive:

      UninstallFilesDir={code:GetDir|0}
      

      Contrary to 1), with this approach the previous installation path won't get reused for the later upgrade/re-install. To implement that see Inno Setup Prompt user for a folder and store the value.

    3. Do not use the CreateInputDirPage, but rather add a second path input box on the "Select Destination Location" page (SelectDirPage).

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