Hello! In the current work there was such a question, what would be better and faster if writing and reading data from an ini file or registry? Is there any scientific summary of what and when it is better to use, the time spent by the program when writing / reading to the registry and to the configuration file? I myself now use the DevExpress component, in particular cxPropertiesStore, which allows you to write data and save changes to the program interface. When too many values ​​are sent to the record (they are written to my registry), this starts to slow down when closing the program. Therefore, I ask what is better ini or the registry, and how to get around this nasty little thing? Thanks in advance to everyone for the answers).

  • "many" is how much? - AntonioK
  • @AntonioK, I will answer that I do not know how much in terms of volume, but I can roughly say how many parameters are being driven there. As I have already said, I use cxPropertiesStore, cxGrid grids (about ten to fifteen), Each grid has from 4-20 fields, and all their properties are sent to the record when the user makes some changes. Because it becomes visually noticeable. - IntegralAL

1 answer 1

Where to store is a difficult task. I personally adhere to the fact that it is better to store in text files (in the same ini files). And here the reason is not in speed, but in convenience - you can always open and correlate. And in the registry, you can only store the path to the ini file (if necessary).

To foul up the registry - just give a reason for every MegaRegistyCleaner to clean up the entries and, theoretically, slow down the system (a couple of entries will not spoil anything, but for sure dozens of megabytes).

Standard TIniFile is rather slow. He calls the system registry functions on the registry for every sneeze, but they are not fast (as far as I understand, they try to flush every time to ensure that all data is written). But Delphi has a "pretender class" - TMemIniFile - which records very quickly, as it keeps everything in memory. The actual entry occurs when calling the destructor or the specialized Update method. It is possible that its speed is more than enough.

If the size of the recorded data is small - a few kilobytes maximum - you can go to the registry; if it is more, it is better to an external file.

Now ini files are "fashionable". More recently, it was very possible to use xml files. And now - json. Although XML states that it is “human readable,” this is not so (in my opinion). But json is nice for editing and reading.

  • Thanks, for a really competent and detailed answer, although I’ll say right away that I use cxPropertiesStore (I mentioned it in the question), there is no alternative to working with the TMemIniFile class, because the solution will not work with “fast” reading and writing ini. The standard class TIniFile is used, therefore in the light of such events), I think the registry will be preferable though. - IntegralAL