Reputation: 795
I need to read a directory path from an ini file at install time.
Under the [Code]
section I have defined a function like
function GetDirectoryFromIni: String;
begin
Result :=
GetIniString('Directories' , 'Name' ,
ExpandConstant('{app}')+'\Default_Path\' ,
ExpandConstant('{app}')+'my_ini_file.ini');
end;
How can I use this function/path/string in the [Files]
section?
Something like:
[Files]
Source: "C:\Source_Directory\*.*"; DestDir: "GetDirectoryFromIni"; \
Flags: ignoreversion
The basic logic is if the user has changed the "Default_Path" from a previous installation I want to adjust to use it, otherwise it uses the default path when the program is first installed.
I cannot seem to define or set a string variable to use the GetDirectoryFromIni
result. Can anyone help?
Upvotes: 2
Views: 498
Reputation: 202088
You can do this even without any Pascal Script code. There's {ini}
"constant":
[Files]
Source: "C:\Source_Directory\*.*"; \
DestDir: "{ini:{app}\my_ini_file.ini,Directories,Name|{app}\Default_Path\}"; \
Flags: ignoreversion
For an answer for your expected solution, see:
Using global string script variable in Run or other section in Inno Setup
Upvotes: 1
Reputation: 795
You need to refer to the function in the [Files] section like
[Files]
Source: "C:\Source_Directory\*.*"; DestDir: "{code:GetDirectoryFromIni}"; Flags: ignoreversion
Then it works.
Upvotes: 0