3

I would like to get the path of the install directory, when the user clicks on Next, when I'm in the wpSelectDir of Inno Setup.

I need to check the path, because I need to verify the path, and if it's not correct, I won't let the user continue.

My problem is that the constant {app} is not set yet, because it will be set after the wpSelectDir and I'm still in.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
kev.g
  • 361
  • 3
  • 15

2 Answers2

2

You can do something like this....

procedure onDirChange(Sender: TObject);
var
    currentDir: String;
begin
    currentDir := WizardForm.DirEdit.Text;
    // your validation goes here....
end;

procedure InitializeWizard;
begin
    WizardForm.DirEdit.onChange := @onDirChange;
end;

The WizardForm.DirEdit.Text returns the current value in the DirEdit Text Box. The procedure onDirChange is called everytime the text in the dirEdit text box changes. You can use this value to perform your validations.

Sam
  • 128
  • 1
  • 5
2

Use WizardDirValue support function:

Returns the current contents of the edit control on the Select Destination Location page of the wizard.

Unlike ExpandConstant('{app}'), this function will not fail if called after the wizard is shown but prior to the user selecting a directory. Rather, it will return the default directory name.


It's more idiomatic than the WizardForm.DirEdit.Text.

Though internally it does nearly the same:

RemoveBackslashUnlessRoot(WizardForm.DirEdit.Text)

See also How do you find the user-selected install path in Inno Setup?

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992