The Registry object provides a simple API for interacting with the Windows Registry. It allows you to create, read, and delete keys and values.
Registry operations use the HKEY enumeration to specify the root key:
HKEY.ClassesRootHKEY.CurrentUserHKEY.LocalMachineHKEY.UsersHKEY.PerformanceDataHKEY.CurrentConfigHKEY.DynData// Create a new key
Registry.CreateKey(HKEY.CurrentUser, '\Software\MyApp\Settings');
// Delete a key
Registry.DeleteKey(HKEY.CurrentUser, '\Software\MyApp\Settings'); Values can be strings, integers, or other basic types.
// Write a string value
Registry.WriteValue(HKEY.CurrentUser, '\Software\MyApp', 'Version', '1.0.0');
// Read a value with a default fallback
var ver := Registry.ReadValue(HKEY.CurrentUser, '\Software\MyApp', 'Version', '0.0.0');
PrintLn('Version: ' + ver);
// Write an integer
Registry.WriteValue(HKEY.CurrentUser, '\Software\MyApp', 'InstallCount', 1); Version: 1.0.0
// Get all subkey names
var subKeys := Registry.SubKeys(HKEY.CurrentUser, '\Software');
// Get all value names in a key
var valNames := Registry.ValueNames(HKEY.CurrentUser, '\Software\MyApp'); Modifying the registry typically requires appropriate user permissions. For example, writing to HKEY.LocalMachine usually requires administrative privileges.