Thursday 11 June 2015

TMemIniFile Vs TIniFile

Ini files have been around for some time now and are very useful for storing small amounts of data, and I use them as an alternative to the registry. Years ago I found that they had been designed with a limit of 64k, however these days it is possible to store more than that. Recently I needed to store a fair bit more than ini files are intended for and after some research decided the way to use them.

There are 2 main classes for reading and writing to ini files TIniFile and TMemIniFile, but which one should you use?

Basically, I found out that TIniFile should be used to write to the file and TMemIniFile should be used to read from the file. A few people mentioned to me to just use the TMemIniFile and you should not use TIniFile, however I believe the TMemIniFile uses an internal hash table which causes writing to the file to be slow. So there it is, use TIniFile to write and TMemIniFile to read.

2 comments:

  1. Done some more tests recently and I am not sure using TIniFile for writing is the best option. I found that writing a section to be faster using TMemInifile.

    ReplyDelete
  2. with TMemIniFile writing you will lose comments placed in the IniFile !

    ReplyDelete