| Previous | Next
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 making modifications. The Registry module automatically creates objects for the top-level registry trees. These objects are created in the $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS $HKEY_PERFORMANCE_DATA $HKEY_CURRENT_CONFIG $HKEY_DYN_DATA If you are outside of the main (default) namespace, you should package declare the keys, e.g., The use Win32::Registry; $p = "SOFTWARE\Microsoft\Windows\CurrentVersion"; $HKEY_LOCAL_MACHINE->Open($p, $CurrVer) || die "Open $!"; This example creates a key object 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:
Win32::Registry MethodsThe following methods can be used on key objects, either on the preopened main keys or subkeys that you have already opened.
$key->Create($newkey, name) Creates a new key identified by name and saves it as the object reference named by
$key->DeleteKey(subkey) Deletes a subkey of the current key. This function will delete all values in the subkey and the subkey itself. A key cannot be deleted if it contains any subkeys.
$key->DeleteValue(name) Deletes a value identified by
$key->GetKeys($listref) Returns the names of the subkeys of the current key to the list referenced by
$key->GetValues($hashref) Returns the values contained in the current key to the hash referenced by
$key->Load(subkey, filename) Loads a registry file to the named
$parent->Open(keyname, $key) Opens a registry key named in keyname and saves it as the object reference named by
$key->QueryKey($class, $subs, $vals) Retrieves information about the current key and returns it to the named scalar variables. The key class is saved in the
$key->QueryValue(name, $var) Returns the value of the registry value specified by
$key->Save(filename) Saves the registry tree root and the current key to a file,
$key->SetValue(subkey, type, value) Sets the default (unnamed) value for the specified subkey of the key object on which
$key->SetValueEx(name, res, type, value) Sets a value specified by
|