Reputation: 7394
I can't figure out why the line below creates a second duplicate section frmR
in an .ini
file that already contains a section with that name.
SetIniString('frmR', 'update', 'true', 'C:\junk\test.ini');
Contents of test.ini
file after installer is run:
We thought this might be an encoding issue (we're using version 5.6.1 (u)). But the section names in a hex viewer are also identical:
Contents of test.ini
file in hex:
A before and after version of the test.ini
file is here: https://drive.google.com/open?id=1vamZxgTvYpAQcOwOnrTpGG63_Bg7i0Js
Below is the barebones .iss
file that demonstrates this problem. Put test.ini
(from the above Google Drive link) in a folder named C:\junk
before running.
[Code]
procedure DeinitializeSetup();
begin
SetIniString('frmR', 'update', 'true', 'C:\junk\test.ini');
end;
I discovered that this problem only occurs if the section is the first section in the file. In other words, the file below works fine (without any duplicate section being added):
[Test section]
Test=test
[frmR]
Top=28
Left=0
The above discovery doesn't resolve the problem, since I have no easy way of assuring that the section I'm writing to is not the first section in the file.
Upvotes: 2
Views: 548
Reputation: 202642
As @Sertac already commented, it is the BOM, for sure. I do not think that Inno Setup creates INI files with BOM. The BOM is just before the first section name. INI file reading/writing functions consider the first line of your file invalid - does not identify it as a section start. Remove the BOM.
Upvotes: 2