TRegistryPersist provides an easy way to persist property values in the system registry.
TObject
TComponent
There are 6 basic steps to using a TRegistryPersist component:
TRegistryPersist works well for creating properties/preferences dialogs, since it allows you to store the last state of the dialog directly to the registry.
property AutoLoad: Boolean;
Read/write
AutoLoad determines whether the TRegistryPersist component automatically loads the properties specified in the Properties property with values from the system registry.
property Key: String;
Read/write
Key specifies the subkey of the root specified by Root that will be used for persisting the property values. This property does not have to be an immediate subkey of the root key, i.e. it may contain backslashes. Editing the property from the Object Inspector will bring up a dialog that can be used to specify the subkey. This dialog can also be used to add or remove keys from the registry.
property Properties: TPropertyPersists;
Read/write
Properties is a collection of TPropertyPersist objects, each of which specifies one property to be persisted in the registry.
property Root: HKEY;
Read/write
Root specifies the starting key in the registry for the Key property. Any open key can be used, as well as the standard keys.
procedure Load;
Loads the values of the specified properties from the registry.
procedure Save;
Saves the values of the specified properties to the registry.
TPropertyPersists is a collection of TPropertyPersist items.
TObject
TPersistent
TCollection
property Items[Index: Integer]: TPropertyPersist;
Read only
Items provides access to the elements of the collection.
property Owner: TRegistryPersist;
Read only
Owner provides access to the owning instance of TRegistryPersist.
function Add: TPropertyPersist;
Add a new TPropertyPersist item to the end of the collection.
function FindItemID(ID: Integer): TPropertyPersist;
Find a TPropertyPersist item by its unique ID. See also TCollection.FindItemID.
function Insert(Index: Integer): TPropertyPersist;
Insert a new TPropertyPersists item at the specified location.
A TPropertyPersist instance specfies the persistence attributes for one property.
TObject
TPersistent
TCollectionItem
property Component: TComponent;
Read/write
Component specifies the component from which the property value will be read or to which the property value will be written.
property PropName: String;
Read/write
PropName specifies the name of the property to be persisted. Only properties with the following types can be persisted:
All other types fail silently on save and load.
property ValueName: String
Read/write
ValueName indicates the name of the registry value that hold the persistent value of the property. By default, ValueName is of the form ComponentName.PropertyName. Unless explicitly specified, ValueName will change whenever Component or PropName changes.