TRegistryIniFile does not work as expected
Original Reporter info from Mantis: Romantiker
-
Reporter name: Manfred Hahn
Original Reporter info from Mantis: Romantiker
- Reporter name: Manfred Hahn
Description:
TRegistryIniFile does not read/write the expected keys and values in the windows registry.
Steps to reproduce:
on a windows system execute something like this:
var RegistryIniFile : TRegistryIniFile;
...
RegistryIniFile.Create('Testsection\Subsection');
RegistryIniFile.WriteString('StringKey','StringLabel','TestString');
...
Look into the registry (regedit) for the key. It has to be
HKEY_CURRENT_USER\Testsection\Subsection\StringKey\StringLabel
with a value 'TestString'.
You will not find it. Neither you will be able to read a string at a known position in the registry.
Additional information:
This is because the FileName given in the TRegistryIniFile.Create constructor is not taken into account in the functions ReadString etc. The actually used registry key always has to be build by concatenation of the FileName and the Section param of the individual functions/procedures.
To overcome this error I have changed the TRegistryIniFile implementation.
I defer all functionality to the TRegIniFile class. TRegIniFile has been extended for reading/writing Float/Time/Date/Datetime-Values.
I have decided not to deal with the CurrentKey, which was preserved in the old code. TRegistryIniFile had been made to be a substitute for TIniFile, where a CurrentKey is not known. If there is a need for preserving CurrentKey it should be done completely in TRegIniFile. But I don't believe this to be necessary.
In the appendix is a diff file with my changes. (diff from trunc)
Mantis conversion info:
- Mantis ID: 22611
- OS: Windows 7
- OS Build: 64-bit
- Platform: Windows
- Version: 2.6.0
- Fixed in version: 3.0.0
- Fixed in revision: 26764 (#4154f531)
- Target version: 3.0.0