innik
innik

Reputation: 21

How to read custom values from INF file in Inno Setup?

Setup programs created with Inno Setup could read an INI file through /LOADINF option. Is it possible to read custom variables through this INI file? Is there a function to get the name of the INI file given with this option? (Then it is possible with the INI utility functions.)

Upvotes: 2

Views: 2109

Answers (2)

s01ipsist
s01ipsist

Reputation: 3137

The code

ExpandConstant('{param:LoadInf}')

provides the file INI file name from the command line parameters.

Use this code if the INF file is in the setup folder

AddBackslash(ExpandConstant('{src}')) + ExpandConstant('{param:LoadInf}');

Upvotes: 2

Oliver Giesen
Oliver Giesen

Reputation: 9459

We simply iterate over the commandline arguments using the ParamStr(i) function and look for an argument starting with "/LOADINF=" and then extract the file name from there.

One gotcha that got us initially was that the file name might be a relative path descriptor (e.g. just the file name). However, if you use compression then the current working directory will be some sub-folder in your %TEMP% folder rather than the directory where your setup.exe is. You should therefore make sure to detect this and prepend the given file name with AddBackslash(ExpandConstant('{src}')) if necessary.

Upvotes: 1

Related Questions