Personal tools
From wiki.swiftlytilting.com
Jump to: navigation, search

WinBinder Manual/wb set registry key

wb_set_registry_key writes a string or integer value to the Windows registry.

Syntax

bool wb_set_registry_key (string key, string subkey [, string entry [, mixed value]])
  • Together, key, subkey and entry reference a value in the Windows registry.
  • If the value does not exist, the function creates it.
  • key can be one of the following values:
    • "HKCU" or "HKEY_CURRENT_USER"
    • "HKLM" or "HKEY_LOCAL_MACHINE"
    • "HKCR" or "HKEY_CLASSES_ROOT"
    • "HKU" or "HKEY_USERS"
    • "HKCC" or "HKEY_CURRENT_CONFIG"
    • "HKD" or "HKEY_DYN_DATA"
  • subkey may contain forward or reverse slashes.
  • If entry is an empty string, a NULL value or is not supplied, the function sets the default value for the subkey.
  • value may be a string, an integer or a floating-point type; if value is NULL, the entry is deleted.


NOTE: Registry keys, subkeys and entries are case-insensitive.

Image:Icon stop.gif A special warning about wb_set_registry_key()

This function provides direct access to the Windows Registry and should be used with great care. This function has the potential to corrupt the Windows Registry, create unexpected behaviors or even render your system useless. Always be careful and double-check your source code before running it when using this function.

Example

// Creates or sets various values

wb_set_registry_key("HKCU", "Software\\WinBinder", "String value", "1234");
wb_set_registry_key("HKCU", "Software\\WinBinder", "Integer value", 1234);
wb_set_registry_key("HKCU", "Software\\WinBinder", "Floating-point value", 1.234);
wb_set_registry_key("HKCU", "Software\\WinBinder", "", "The default");

// Delete the new entries

wb_set_registry_key("HKCU", "Software\\WinBinder", "String value", null);
wb_set_registry_key("HKCU", "Software\\WinBinder", "Integer value");
wb_set_registry_key("HKCU", "Software\\WinBinder", "Floating-point value");
wb_set_registry_key("HKCU", "Software\\WinBinder", "");

See also

Winbinder Projects