1

I'm writing an Inno Setup wizard to install a plugin. Some of the files I need to move can only be known at installation time. I.e., I would like to do something like this:

[Files]
Source: "a/regular/file.txt"; DestDir: "{app}/bin"
Source: "{User Directory}/filetwo.txt"; DestDir: "{app}/bin"

How can I query the user to browse their filesystem for a specific directory and then use that value as a Source file? I can create a Page that lets the user browse their filesystem, but how do I then get that value back out?

Right now I have something that looks like this:

[Files]
Source: "{code:GetUserDir}/file.txt"; Destdir: "{app}/bin"; Flags external;

[Code]
var
    UserDir: String;
    UserDirPage: TInputDirWizardPage;

procedure InitializeWizard;
begin

UserDirPage := CreateInputDirPage(
  wpSelectDir,
  'Window Title',
  '',
  'Please pick a folder.',
  False,
  '');
UserDirPage.Add('');
UserDir := UserDirPage.Values[0];
end;

function GetUserDir : String;
begin
  Result := UserDir;
end

I believe the problem is in my [Files] section. This code launches a wizard with a window that accepts a user directory, but when I add the {code:GetUserDir} Source line it fails to compile with error 'Invalid prototype for 'GetUserDir'. Get rid of this and it runs, but I can't access that variable in my Source directory.

Any ideas?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
N. Murray
  • 21
  • 2

0 Answers0