Mega Code Archive

 
Categories / Delphi / System
 

The windows registry

Title: The windows registry Question: How can I work with the windows registry? Answer: { Here's an example of how to use the windows registry; } uses Registry, Windows; procedure TForm1.Button1Click(Sender: TObject); var Registry: TRegistry; begin { create TRegistry Object } Registry := TRegistry.Create; { set the rootkey; e.g. hkey_local_machine or hkey_current_user } Registry.RootKey := hkey_local_machine; { opens and create the key } Registry.OpenKey('software\MyRegistryExample',true); { write value } Registry.WriteString('MyRegistryName','MyRegistry Value'); { close and free the key } Registry.CloseKey; Registry.Free; end;