How do you read the ini-fail contents during installation?
-
It shall be necessary to read the values from one ini-fail at the time of installation and to record them in another ini-fill. The function of reading the line from the ini-fail somehow returns the default value to it, not the file. File's lying there, there's a point in it.
This is the example of the crypt, which reproduces the problem:
[Setup] AppName=MyApp AppVersion=1 DefaultDirName=D:\Projects\Test\ DisableDirPage=yes Uninstallable=no
[INI]
Filename: "{app}\INIFile2.ini"; Section: "Section"; Key: "Key1"; String: "{code:GetIniFileValue|'Key1'}"
Filename: "{app}\INIFile2.ini"; Section: "Section"; Key: "Key2"; String: "{code:GetIniFileValue|'Key2'}"[Code]
function GetIniFileValue(const Key: String): String;
begin
Result := GetIniString('Section', Key, 'DefaultValue', 'D:\Projects\Test\INIFile1.ini');
MsgBox(Result, mbInformation, MB_OK); // сообщение выводит результат функции GetIniString
end;
Contained file
INIFile1.ini
:[Section]
Key1=Value1
Key2=Value2
Once the installation has been completed, the file will be delivered
INIFile2.ini
of the following contents:[Section]
Key1=DefaultValue
Key2=DefaultValue
How do I get the first file?
-
The error was in the transfer of parameters to the function, the parameters were to be stated without single quotes:
[INI] Filename: "{app}\INIFile2.ini"; Section: "Section"; Key: "Key1"; String: "{code:GetIniFileValue|Key1}" Filename: "{app}\INIFile2.ini"; Section: "Section"; Key: "Key2"; String: "{code:GetIniFileValue|Key2}"
UPD: I found another excellent version of reading ini-fail without adding the code.
Filename: "{app}\INIFile2.ini"; Section: "Section"; Key: "Key1"; String: "{ini:{app}\INIFile1.ini,Section,Key1}"