Show: Object Pascal C++
Display Preferences

Using TRegistryIniFile

From Appmethod Topics
Jump to: navigation, search

Go Up to Working with ini Files and the System Registry

Many 32-bit Windows applications store their information in the system Registry instead of ini files because the Registry is hierarchical and doesn't suffer from the size limitations of ini files. If you are accustomed to using ini files and want to move your configuration information to the Registry instead, you can use the System.Win.Registry.TRegistryIniFile class.

You may also want to use TRegistryIniFile in multi-device applications, for example, if you want to use the system Registry on Windows and an ini file on OS X. You can write most of your application so that it uses the TCustomIniFile type. For multi-device, you need only conditionalize the code that creates an instance of TRegistryIniFile (on Windows) or TMemIniFile (on Linux) and assigns it to the TCustomIniFile that your application uses.

TRegistryIniFile makes Registry entries look like ini file entries. All the methods from TIniFile and TMemIniFile (read and write) exist in TRegistryIniFile.

When you construct a TRegistryIniFile object, the parameter you pass to the constructor (corresponding to the filename for an IniFile or TMemIniFile object) becomes a key value under the user key in the registry. All sections and values branch from that root. TRegistryIniFile simplifies the Registry interface considerably, so you may want to use it instead of the TRegistry component even if you aren't porting existing code or writing a multi-device application.

See Also

Personal tools
In other languages