Skip to content

TMiletusRegistry

TMiletusRegistry allows to create/read/write/delete registry values on Windows. On macOS and Linux it falls back onto an INI file that is automatically created next to the binary application if it doesn't exists yet. Below is a list of available properties and methods for TMiletusRegistry.

Properties for TMiletusRegistry

Property Description
RootKey: TMiletusRegistryRootKey Sets the root key. Accepted values are:
MILETUS_CLASSES_ROOT,
MILETUS_CURRENT_USER,
MILETUS_LOCAL_MACHINE,
MILETUS_USERS,
MILETUS_CURRENT_CONFIG
Access: LongWord Sets the access rights. Accepted values are: KEY_ALL_ACCESS, KEY_WRITE, KEY_READ

Methods for TMiletusRegistry

Property Description
CloseKey: TJSPromise Function to close the key that is currently opened. The return value of the TJSPromise is nil.
CreateKey(const Key: string): TJSPromise Function to create a key. The return value of the TJSPromise is Boolean.
DeleteKey(const Key: string): TJSPromise Function to delete a key. The return value of the TJSPromise is Boolean.
DeleteValue(const Name: string): TJSPromise Function to delete a value from a key. The return value of the TJSPromise is Boolean.
KeyExists(const Key: string): TJSPromise Function to check if Key exists under RootKey. The return value of the TJSPromise is Boolean.
OpenKey(const Key: string; CanCreate: Boolean): TJSPromise Function to open a given Key under the RootKey. If Key does not exists, and CanCreate is True, it will create Key. The return value of the TJSPromise is Boolean.
ValueExists(const Name: string): TJSPromise Function to check if a value exists in a key. The return value of the TJSPromise is Boolean.
ReadCurrency(const Name: string): TJSPromise Function to read a Currency value from the registry. The return value of the TJSPromise is Currency.
ReadBinaryData(const Name: string; var Buffer: TBytes; BufSize: Integer): TJSPromise Function to read binary value from the registry into Buffer. The return value of the TJSPromise is Integer.
ReadBool(const Name: string): TJSPromise Function to read a boolean value from the registry. The return value of the TJSPromise is Boolean.
ReadDate(const Name: string): TJSPromise Function to read a date value from the registry. The return value of the TJSPromise is TDateTime.
ReadDateTime(const Name: string): TJSPromise Function to read a datetime value from the registry. The return value of the TJSPromise is TDateTime.
ReadFloat(const Name: string): TJSPromise Function to read a float value from the registry. The return value of the TJSPromise is Double.
ReadInteger(const Name: string): TJSPromise Function to read an integer value from the registry. The return value of the TJSPromise is Integer.
ReadString(const Name: string): TJSPromise Function to read a string value from the registry. The return value of the TJSPromise is string.
ReadTime(const Name: string): TJSPromise Function to read a time value from the registry. The return value of the TJSPromise is TDateTime
WriteCurrency(const Name: string; Value: Currency) Method to write a currency value to the registry.
WriteBinaryData(const Name: string; const Buffer: TBytes; BufSize: Integer) Method to write binary value from Buffer to the registry.
WriteBool(const Name: string; Value: Boolean) Method to write a boolean value to the registry.
WriteDate(const Name: string; Value: TDateTime) Method to write a date value to the registry.
WriteDateTime(const Name: string; Value: TDateTime) Method to write a datetime value to the registry.
WriteFloat(const Name: string; Value: Double) Method to write a float value to the registry.
WriteInteger(const Name: string; Value: Integer) Method to write a integer value to the registry.
WriteString(const Name, Value: string) Method to write a string value to the registry.
WriteExpandString(const Name, Value: string) Method to write an expanded string value to the registry.
WriteTime(const Name: string; Value: TDateTime) Method to write a time value to the registry.

Example usage:

procedure TForm1.WebButton1Click(Sender: TObject); async;
var
  reg: TMiletusRegistry;
  b: Boolean;
  s: string;
begin
  reg := TMiletusRegistry.Create;
  try
    reg.RootKey := MILETUS_CURRENT_USER;
    b := await(Boolean, reg.OpenKey('SOFTWARE\tmssoftware\TMS Web
Core\Test1\', False));
    if b then
    begin
      s := Await(string, reg.ReadString('StringValue'));
      WebMemo1.Lines.Add(s);
    end;
  finally
    reg.Free;
  end;