19.13 Win32::RegistryThis module provides access to the Windows Registry, the database that stores information about all parts of your system and software. Many operating system and application behaviors are controlled by Registry data. The Win32::Registry module gives you a way to access and update registry information with Perl. (Warning: Always be careful when making changes to the registry. If vital system information gets changed by mistake, your system could become inoperable. Always make certain you have a backup of your registry before you start to make modifications.)
The Registry module automatically creates objects for the top-level registry
trees. These objects are created in the If you are outside of the main (default) namespace, you should package declare the keys, i.e.,$HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$main::HKEY_USERS
.
The This example creates a key objectuse Win32::Registry; $p = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"; $HKEY_LOCAL_MACHINE->Open($p, $CurrVer) || die "Open $!";
$CurrVer
for the
CurrentVersion
key for Windows NT. This key contains several values
for the version of the operating system. With the new key open, you can
read or change the values it contains (every key has at least one unnamed,
default value), or open and create subkeys.
The
Open
method can only create key objects for existing keys.
Registry values are represented in Win32::Registry functions by three elements: the name of the value, the data type of the value, and the value itself. There are several different data types for the values. Win32::Registry defines the following constants for these types: REG_SZ String data REG_DWORD Unsigned four-byte integer REG_MULTI_SZ Multiple strings delimited with NULL REG_EXPAND_SZ Strings that expand (e.g., based on environment variables) REG_BINARY Binary data (no particular format is assumed) 19.13.1 MethodsThe following methods can be used on key objects, either the preopened main keys or subkeys that you have already opened.
|
|