2
votes

I have an Inno Setup Pascal script that prompts the user for 4 folders. Three of the folders should already exist. The 4th being used as a placeholder where I am going to mount a VHD disk in the future. So all I use is the string value of this folder.

When the user runs the script, he gets an error that the UNC path does not exist (well, yes, it should not exist. For example, if he said "L:\myfolder" then the L: drive is not loaded yet, and there is no disk there. That is correct. My Inno Setup script will load it for you later.

How can I disable checking for the folder?

FoldersPage := CreateInputDirPage(InfoPage.ID,
  'FoldersSettings', 'Customize folders settings for non-standard EGPL systems',
  'If the defaults are acceptable, then click Next.',
  False, 'New Folder');
FoldersPage.Add('GeoPackage Output Folder');
FoldersPage.Add('VHD Mount Path for GeoLibrarian');
FoldersPage.Add('EGPL Source Folder');
FoldersPage.Add('WWW Root Folder');
1
Check my answer to an identical question to see a workaround. linkPLopes

1 Answers

2
votes

You cannot disable the validation.

You can workaround that by adding only three inputs using the .Add. And add the fourth input manually, taking control of it.

var
  DataDirPage: TInputDirWizardPage;
  CustomDirEdit: TEdit;

procedure InitializeWizard;
var
  Index: Integer;
  Offset: Integer;
  PromptLabel: TNewStaticText;
  UltimateEdit: TEdit;
  PenultimateEdit: TEdit;
  UltimateLabel: TNewStaticText;
begin
  DataDirPage := CreateInputDirPage(wpSelectDir,
    'FoldersSettings', 'Customize folders settings for non-standard EGPL systems',
    'If the defaults are acceptable, then click Next.',
    False, 'New Folder');

  DataDirPage.Add('GeoPackage Output Folder');
  Index := DataDirPage.Add('VHD Mount Path for GeoLibrarian');
  PenultimateEdit := DataDirPage.Edits[Index];
  Index := DataDirPage.Add('EGPL Source Folder');
  UltimateEdit := DataDirPage.Edits[Index];
  UltimateLabel := DataDirPage.PromptLabels[Index];

  Offset := UltimateEdit.Top - PenultimateEdit.Top;

  PromptLabel := TNewStaticText.Create(WizardForm);
  PromptLabel.Top := UltimateLabel.Top + Offset;
  PromptLabel.Width := UltimateLabel.Width;
  PromptLabel.Height := UltimateLabel.Height;
  PromptLabel.Parent := DataDirPage.Surface;
  PromptLabel.Caption := 'WWW Root Folder';

  CustomDirEdit := TEdit.Create(WizardForm);
  CustomDirEdit.Top := UltimateEdit.Top + Offset;
  CustomDirEdit.Width := UltimateEdit.Width;
  CustomDirEdit.Parent := DataDirPage.Surface;

  PromptLabel.FocusControl := CustomDirEdit;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;

  if CurPageID = DataDirPage.ID then
  begin
    if CustomDirEdit.Text = '' then
    begin
      MsgBox('You must enter WWW Root Folder.', mbError, MB_OK);
      Result := False;
    end;

    // Any other validation
  end;
end;

This does not feature the Browse button. It's yet more work and I'm not sure, if it makes sense, as the input is used to input a path to a drive that does not exist.

enter image description here