Registry.OpenKey

Top  Previous  Next

 

Syntax

function Registry.OpenKey(Registry: pointer; Key: string; CanCreate: boolean): boolean

 

Alternative Names

ibec_reg_OpenKey

 

Description

Opens a registry key in the rootkey for the given Registry object, if the key doesn't exist, the CanCreate parameter determines if the key is created.

 

Returns TRUE if the key is opened or created, FALSE otherwise.

 

See also

Registry.Open
Registry.CreateKey
Registry.DeleteKey
Registry.KeyExists
Registry.CloseKey

 

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;