Registry.Open

Top  Previous  Next

 

Syntax

function Registry.Open(RootKey: integer; Access: positive-integer): pointer

 

Alternative Names

ibec_reg_Open

 

Description

Creates a new registry object for the given RootKey that can be used to open sub-keys, read and write values. You can destroy the object using Registry.Free.

 

The Access parameter is currently ignored.

 

Returns a registry object if successful, or NULL otherwise.

 

RootKey can be one of these predefined constants:

__HKEY_CLASSES_ROOT
__HKEY_CURRENT_USER
__HKEY_LOCAL_MACHINE
__HKEY_USERS
__HKEY_CURRENT_CONFIG

 

See also

Registry.OpenKey
Registry.Free

 

Example

execute udsblock 

returns( out_vc varchar(1000), out_int integer, out_float double precision, out_time timestamp)

as

begin

  reg = Registry.Open(__HKEY_CURRENT_USER, 0);

  try

     /* returns -1 (true) */

  out_int = Registry.OpenKey(reg, '\Software\Upscene\DScript\Test', __TRUE);

  

  /* this key doesn't exist, so this returns 0 (false) */

  out_int = Registry.KeyExists(reg, 'Newkey');

  

     /* write string value, value name now exists */

  Registry.WriteString(reg, 'NewValue', 'string');

  out_int = Registry.ValueExists(reg, 'NewValue');

  /* returns -1 (true) */

  Registry.DeleteValue(reg, 'NewValue');

  out_int = Registry.ValueExists(reg, 'NewValue');

  /* returns 0 (false) again */

  

  /* write and read several values */

  Registry.WriteInteger(reg, 'NameInt', 12);

  out_int = Registry.ReadInteger(reg, 'NameInt');

  

  Registry.WriteFloat(reg, 'NameFloat', 13.13);

  out_float = Registry.ReadFloat(reg, 'NameFloat');

  

  Registry.WriteBool(reg, 'NameBool', __FALSE);

  out_int = Registry.ReadBool(reg, 'NameBool');

  

  Registry.WriteTime(reg, 'NameTime', TIME'12:13');

  out_time = Registry.ReadTime(reg, 'NameTime');

  

  Registry.WriteDate(reg, 'NameDate', DATE'2024-12-23');

  out_time = Registry.ReadDate(reg, 'NameDate');

  

  Registry.WriteDateTime(reg, 'NameDateTime', TIMESTAMP'2024-12-23 12:13');

  out_time = Registry.ReadDateTime(reg, 'NameDateTime');

  

  Registry.CloseKey(reg);

  /* delete the test key */

  out_int = Registry.DeleteKey(reg, '\Software\Upscene\DScript\Test');

  /* test key existence, returns 0 (false) */

  out_int = Registry.KeyExists(reg, '\Software\Upscene\DScript\Test');

  finally

    Registry.Free(reg);

  end

end;