I'm creating an Installer using Inno Setup. I have to take two paths from user. One for program executables and another for libs. The default app folder is {pf}/companyname/applicationname
In the InitializeWizard
I have created second page which takes the lib folder from the user.
Is there any way to change the default lib folder to the user selected folder {app}
?
I have tried WizardDirValue
. It just gives the default {app}
value and NOT the path which user selected in first page.
[code]
procedure InitializeWizard();
begin
page2:= CreateInputDirPage(wpProgress,
'Select Library Location', 'Where Library files should be stored?',
'To continue, click Next. If you would like to select a different folder, click Browse.',
False, 'Libs');
page2.Add('');
page2.Values[0] := WizardDirValue+'\libs';
LibDir := page2.Values[0];
end
As the name
InitializeWizard()
shows you it is an initialization function, called only once, before the wizard is shown. You can test this yourself by setting a breakpoint on your code - it will be hit only once, right at the start.It's therefore the correct place to add a new wizard page and set the default value of any control, but it's impossible to react on changes to other wizard pages. What you need to do is to update the library path right before your page is shown. The correct way to do this is the
NextButtonClick()
function. Here is some sample code:This will add your page right after the page that queries the
{app}
directory. Since the user can click the "Prev" button to change the{app}
directory multiple times you should always update the library path when your page is about to be shown:For better usability you could also check that the library directory is the default value, and otherwise don't change its value.
You can use the ExpandConstant function. In it, all Inno Setup constants are replaced with their real values. For example, ExpandConstant('{app}\mydir') should become C:\Program Files\\mydir.