stringlistcontainer LoadFromRegistry method
Return to Introduction  Previous page  Next page
Applies to
acStringListContainer component.  

Declaration
procedure LoadToRegistry(Reg: TRegistry); overload;  
procedure LoadToRegistry(const KeyName: Stringconst RootKey: hKey = HKEY_CURRENT_USER); overload;  

Description
The LoadToRegistry method loads the strings to the from the registry.  
 
There is 2 overloaded methods of calling the LoadFromRegisty:  
1. The registry key must be previously opened and handle to TRegistry object must be passed with Reg parameter (see first example below);  
2. You must pass the KeyName and the RootKey (HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE) as parameters (see second example below).  

Screenshot from RegEdit (demonstrates how the values should be stored in registry to load them. They can be previously stored in this form with StoreToRegistry method)
acstringlistcontainerregss  

Example 1
(if the TRegistry object already prepared before saving of the strings)
uses Registry;  
 
procedure TForm1.Button1Click(Sender: TObject);  
var  
  MyKey: String;  
  Reg: TRegistry;  
begin  
  MyKey := 'SOFTWARE\My Company Name\My Program Name\StringList';  
 
  Reg := TRegistry.Create;  
  with Reg do  
   try  
     RootKey := HKEY_CURRENT_USER;  
     if OpenKey(MyKey, False) then  
       acStringListContainer1.LoadToRegistry(Reg);  
   finally  
     Free;  
   end;  
end;  

Example 2 (if we want to pass the KeyName and RootKey as parameters without preparing of the TRegistry object)
procedure TForm1.Button1Click(Sender: TObject);  
begin  
  acStringListContainer1.LoadToRegistry('SOFTWARE\My Company Name\My Program Name\StringList');  
end;

See also
StoreToRegistry, SaveToFile and LoadFromFile methods;  
Strings, Names, Values, MaxSize and Duplicates properties.