Use two / more selected directories from the user page in the Files section

I need to create a custom page from two destinations.

I did:

#define MyAppName "TESTPROG" [Setup] AppName={#MyAppName} DefaultDirName=C:\test\{#MyAppName} DefaultGroupName={#MyAppName} [Code] var Page: TInputDirWizardPage; DataDir: String; procedure InitializeWizard; begin Page := CreateInputDirPage(wpWelcome, 'Select Personal Data Location', 'Where should personal data files be stored?', 'Personal data files will be stored in the following folder.'#13#10#13#10 + 'To continue, click Next. ' + 'If you would like to select a different folder, click Browse.', False, 'New Folder'); Page.Add('Local APP'); Page.Add('Local Storage'); Page.Values[0] := ('C:\My Program'); Page.Values[1] := ('D:\My Program'); DataDir := Page.Values[0]; end; 

I need to know how and where I set DefaultDirName with Page.Values[0] and Page.Values[1]

I need this because part of my files will be in a folder, and others in a different folder.

For instance:

 [Files] Source: C:\TEST\DLL1.bat; DestDir: Page.Values[0]\sys1; Source: C:\TEST\DLL2.bat; DestDir: Page.Values[1]\sys2; 
+1
source share
1 answer

Use scripting 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 (first) paths from the TInputDirWizardPage instead of the path from the "Select Destination" page, you have three options.

  • Disable the "Choose Destination" page using the DisableDirPage directive :

     DisableDirPage=yes 

    Copy the path from TInputDirWizardPage to the hidden "Select Destination Location" when the user clicks the 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; 

    In addition to the fact that you can also consider copying the original WizardForm.DirEdit to your own. Thus, you will make sure that 1) when reinstalling / updating the previously selected value is reused; 2) /DIR command line switch works. To do this, see How to get the Inno Setup / DIR command line switch to work with a custom path page .

  • Replace all applications {app} constant with {code:GetDir|0} .

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

     CreateAppDir=no 

    (this means DisableDirPage=yes ).

    And save the uninstall files in the first path using the UninstallFilesDir directive :

     UninstallFilesDir={code:GetDir|0} 

    Unlike 1), with this approach, the previous installation path will not be reused for subsequent updates / reinstallations. To implement this, see Inno Setup Request a user for a folder and save the value .

  • Do not use CreateInputDirPage , but add a second path input field on the Select Destination page ( SelectDirPage ).

+2
source

Source: https://habr.com/ru/post/974790/


All Articles