This module provides read and write access to the registry on Windows. It is essentially a port driver wrapped around the Win32 API calls for accessing the registry.
The registry is a hierarchical database, used to store various system and software information in Windows. It contains installation data, and is updated by installers and system programs. The Erlang installer updates the registry by adding data that Erlang needs.
The registry contains keys and values. Keys are like the directories in a file system, they form a hierarchy. Values are like files, they have a name and a value, and also a type.
Paths to keys are left to right, with subkeys to the right and backslash between keys. (Remember that backslashes must be doubled in Erlang strings.) Case is preserved but not significant.
For example,
There are six entry points in the Windows registry, top-level keys. They can be abbreviated in this module as follows:
Abbreviation Registry key ============ ============ hkcr HKEY_CLASSES_ROOT current_user HKEY_CURRENT_USER hkcu HKEY_CURRENT_USER local_machine HKEY_LOCAL_MACHINE hklm HKEY_LOCAL_MACHINE users HKEY_USERS hku HKEY_USERS current_config HKEY_CURRENT_CONFIG hkcc HKEY_CURRENT_CONFIG dyn_data HKEY_DYN_DATA hkdd HKEY_DYN_DATA
The key above can be written as
This module uses a current key. It works much like the current directory. From the current key, values can be fetched, subkeys can be listed, and so on.
Under a key, any number of named values can be stored. They have names, types, and data.
Other types can be read, and are returned as binaries.
There is also a "default" value, which has the empty string as name. It
is read and written with the atom
Some registry values are stored as strings with references to environment
variables, for example,
For more information on the Windows registry, see consult the Win32 Programmer's Reference.
As returned by
Changes the current key to another key. Works like
Creates a key, or just changes to it, if it is already there. Works
like a combination of
The registry must have been opened in write mode.
Closes the registry. After that, the
Returns the path to the current key. This is the equivalent of
Notice that the current key is stored in the driver, and can be invalid (for example, if the key has been removed).
Deletes the current key, if it is valid. Calls the Win32 API
function
Deletes a named value on the current key. The atom
The registry must have been opened in write mode.
Expands a string containing environment variables between percent
characters. Anything between two
A variable name that is not in the environment results in an error.
Converts a POSIX error code to a string
(by calling
Opens the registry for reading or writing. The current key is the
root (
Use
Sets the named (or default) value to
Other types cannot be added or changed.
The registry must have been opened in write mode.
Returns a list of subkeys to the current key. Calls the Win32
API function
Avoid calling this on the root keys, as it can be slow.
Retrieves the named value (or default) on the current key.
Registry values of type
Retrieves a list of all values on the current key. The values
have types corresponding to the registry types, see