win32reg

win32reg provides access to the registry on Windows

win32reg 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 is available in Windows 95 and
Windows NT. 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 sub-keys to the right and backslash
between keys. (Remember that backslashes must be doubled in Erlang strings.)
Case is preserved but not significant.
Example: "\\hkey_local_machine\\software\\Ericsson\\Erlang\\5.0" is the key
for the installation data for the latest Erlang release.

There are six entry points in the Windows registry, top level keys. They can be
abbreviated in the win32reg module as:

The key above could be written as "\\hklm\\software\\ericsson\\erlang\\5.0".

The win32reg module uses a current key. It works much like the
current directory. From the current key, values can be fetched, sub-keys
can be listed, and so on.

Under a key, any number of named values can be stored. They have name, and
types, and data.

Currently, the win32reg module supports storing only the following
types: REG_DWORD, which is an
integer, REG_SZ which is a string and REG_BINARY which is a binary.
Other types can be read, and will be returned as binaries.

There is also a "default" value, which has the empty string as name. It is read and
written with the atom default instead of the name.

Some registry values are stored as strings with references to environment variables,
e.g. "%SystemRoot%Windows". SystemRoot is an environment variable, and should be
replaced with its value. A function expand/1 is provided, so that environment
variables surrounded in % can be expanded to their values.

For additional information on the Windows registry consult the Win32
Programmer's Reference.

delete_key(RegHandle) -> ReturnValue

Deletes the current key, if it is valid. Calls the Win32 API
function RegDeleteKey(). Note that this call does not change the current key,
(unlike change_key_create/2.) This means that after the call, the
current key is invalid.

delete_value(RegHandle, Name) -> ReturnValue

Deletes a named value on the current key. The atom default is
used for the the default value.

The registry must have been opened in write-mode.

expand(String) -> ExpandedString

String = ExpandedString = string()

Expands a string containing environment variables between percent
characters. Anything between two % is taken for a environment
variable, and is replaced by the value. Two consecutive % is replaced
by one %.

A variable name that is not in the environment, will result in an error.

format_error(ErrorId) -> ErrorString

ErrorId = atom()

ErrorString = string()

Convert an POSIX errorcode to a string (by calling erl_posix_msg:message).

set_value(RegHandle, Name, Value) -> ReturnValue

Sets the named (or default) value to value. Calls the Win32
API function RegSetValueEx(). The value can be of three types, and
the corresponding registry type will be used. Currently the types supported
are: REG_DWORD for integers, REG_SZ for strings and
REG_BINARY for binaries. Other types cannot currently be added
or changed.

value(RegHandle, Name) -> ReturnValue

Retrieves the named value (or default) on the current key.
Registry values of type REG_SZ, are returned as strings. Type REG_DWORD
values are returned as integers. All other types are returned as binaries.