Delphi writing duplicate entries to TIniFile

Viewed 209

Here's a curious phenomenon. I have a Delphi 10.3 application that has started writing duplicate entries to a TIniFile.

Here's the code:

with TIniFile.Create(UserDatFileName) do
try
  WriteInteger(SFormName, 'Top', AForm.Top);
  WriteInteger(SFormName, 'Left', AForm.Left);
  WriteInteger(SFormName, 'Height', AForm.Height);
  WriteInteger(SFormName, 'Width', AForm.Width);
  WriteString(SFormName, 'WindowState', SWindowState);
finally
  Free;
end;

This has worked fine for years. Now, all of a sudden, I'm getting output like this:

[fMainForm]
Top=0
Left=0
Height=556
Width=671
WindowState=wsMaximized
pnlNavigation.Width=165
TreeListcxTreeListModule.Width=161
Top=0
Left=0
Height=556
Width=671
WindowState=wsMaximized
pnlNavigation.Width=165
TreeListcxTreeListModule.Width=161
Top=0
Left=0
Height=556
Width=671
WindowState=wsMaximized
pnlNavigation.Width=165
TreeListcxTreeListModule.Width=161
... etcetera etcetera

Any suggestions about why this might be happening? I thought TIniFile value pairs were supposed to be unique within each section?

1 Answers

@dummzeuch for the win: there were three extraneous characters (Hex EF BB BF) at the beginning of the file. Removing those removed the problem. I also found the same three characters at the start of another similarly problematic INI file.

Related