2
votes

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:

enter image description here

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:

enter image description here

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.

1
Did you test without the BOM?Sertac Akyuz
@SertacAkyuz No I did not test without the BOM. These ini files (with the BOM) are created by Inno, so I didn't think that testing a BOM-less file would provide any additional information.RobertFrank
It may not. It was just an idea.Sertac Akyuz

1 Answers

2
votes

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.