Berkeley CSUA MOTD:Entry 33841
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/04/06 [General] UID:1000 Activity:popular
4/6     

2004/9/29-30 [Computer/SW/Languages/Perl] UID:33841 Activity:nil
9/29    How do I use perl to delete some registry setting? such as
        HKCR\Something. I want to automatically nuke the entry...
        Thanks...
        \_ From the 1st google result for 'perl registry'
           http://jenda.krynicky.cz/perl/Registry.pm.html
           Load the Win32:Registry module and go from there...
Cache (8192 bytes)
jenda.krynicky.cz/perl/Registry.pm.html
print $HKLM->Open('SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Tips')->GetValue('32'); DESCRIPTION This module creates an object oriented interface to registry. It allows you to read&update local as well as remote registry. Editing registry can easily render you computer unusable. The predefined base objects are : $HKEY_LOCAL_MACHINE (shortcut = $HKLM) Informations about the local computer system, including hardware and OS. Data are updated at startup and whenever the system configuration is modified. It also contains some performance data under under Hkey_Dyn_Data\PerfStats. Note that the performance data are not stored in the Registry database. ReqQueryKeyEx will cause the system to collect the data. You may use this to copy a whole registry key with all subkeys into a different branch. Both the $key and $to may be either paths or registry objects. The $to MUST already exist, the copy will be created UNDER this key. DEFAULT\SOFTWARE\Jenda\ThisScript\'s defaults',$to,'ThisScript'); If you do not specify the $filename, the text gets printed to the currently select()ed filehandle. If the $continuation is defined, no header is printed out. If you do not want to specify the filename, but need continuation, use undef() as the $filename. If you call this function using the first syntax, it recurses through the registry and calls &function you passed before precessing each key. If the &leavefunction is defined, it is being called AFTER processing the subkeys. The key is passed to &function (or \&leavefunction) as it's first parameter. If you use the other form, each time the &bool_function returns true FindKey pushes the path of the active key to @array. You may instruct the method to skip processing the subkeys of the current key by seting $Win32::Registry::Find::skip_subkeys variable to 1 in the callback function. You may also define functions to be called when 1 entering the key - &KeyEnterFunction 2 finished processing the values, but before recursing into subkeys - &KeyLeaveFunction 3 finished processing all subkeys - &SubKeysLeaveFunction The &function get's its parameters through global variables : Win32::Registry::Find::key - the key in which the value resides Win32::Registry::Find::name - the name of the value Win32::Registry::Find::type - the type of the value Win32::Registry::Find::value - the value If you set the $Win32::Registry::CFG{'value_objects'} variable, the &function gets a Win32::Registry::Value object as it's first parameter. The other functions get a registry object pointing to the current key as their first and only argument. Win32::Registry | Base objects | Methods and functions | Constants and Variables FlushKey $obj->FlushKey() The FlushKey function writes all the attributes of the specified open key into the registry. Registry changes are flushed to disk by the registry using its lazy flusher. Registry changes are also flushed to disk at system shutdown. Close, the FlushKey function returns only when all the data has been written to the registry. The FlushKey function may also write out parts of or all of the other keys. Calling this function excessively can have a negative effect on an application's performance. An application should only call FlushKey if it requires absolute certainty that registry changes are on disk. Win32::Registry | Base objects | Methods and functions | Constants and Variables ForKeys $obj->ForKeys(\&fun); The name of the subkey is in the first parameter to the function, the current key object is in $_. Win32::Registry | Base objects | Methods and functions | Constants and Variables GetKeys $obj->GetKeys(\@ARRAY) @ARRAY = $obj->GetKeys() Get the list of subkeys of current key. In scalar context returns true or false, in array context returns an array of subkeys. QueryType Win32::Registry | Base objects | Methods and functions | Constants and Variables GetValue $value = $obj->GetValue("value name") $obj->GetValue("value name",$value) This is what Query value should be. It returns the named value from the current key, instead of the default value of the named subkey. If you want the default value from the current key use '' as the name. QueryValueEx Win32::Registry | Base objects | Methods and functions | Constants and Variables GetValues $obj->GetValues(\%HASH) GetValues creates a hash containing 'name'=> ( name,type,data ) for each value in the current key. Win32::Registry | Base objects | Methods and functions | Constants and Variables GetOnlyValues $obj->GetOnlyValues(\%HASH) Similar to GetValues, the created HASH contains only the values ($HASH{name} = value''). If the $obj points to a key at a remote computer, the script will be imported into that computer instead of the local registry. The optional \&keyfun and \&valuefun parameters give you a way to control what is imported and where. This function may change the key to where will be the values imported, the value it returns will be used as the name (path) of the key to save the values into. The &valuefun (if present) is called for each value imported. A hive is a discrete body of keys, subkeys, and values that is rooted at the top of the registry hierarchy. The $obj should be either HKEY_LOCAL_MACHINE or HKEY_USERS in the local or remote registry. If you pass REG_LOADTEMPORARY as the third parameter, the hive will be automaticaly unloaded at the end of script. You may not load parts of Win95 registry on WinNT and vice versa! Windows NT: The owner of the calling process must have the SE_RESTORE_NAME privilege. Windows 95: Security privileges are not supported nor required. Win32::Registry | Base objects | Methods and functions | Constants and Variables UnLoad $obj->UnLoad($SubKey) Unloads a part of registry previously loaded by Load (RegLoadKey). The $obj should be either HKEY_LOCAL_MACHINE or HKEY_USERS. You may use this to move a whole registry key with all subkeys into a different branch. Both the $key and $to may be either paths or registry objects. The $to MUST already exist, the key will be moved UNDER this key. DEFAULT\SOFTWARE\Jenda\ThisScript\'s defaults',$to,'ThisScript'); Win32::Registry | Base objects | Methods and functions | Constants and Variables Num2Object $object = Win32::Registry::Num2Object($handle) Makes a new object out of a handle number. The created object is returned through the second parameter and as the function result. If the first parameter starts by a backslash it is considered an absolute path from the object's root. The created object is returned through the second parameter and as the function result. Posible values are KEY_ALL_ACCESS Full access (read, write, delete) KEY_READ Read-only access KEY_WRITE Write-only access If the first parameter starts by a backslash it is considered an absolute path from the object's root. Win32::Registry | Base objects | Methods and functions | Constants and Variables QueryInfoKey $obj->QueryInfoKey($class, $classsz, $reserved, $numsubkeys,$maxsubkey, $maxclass, $values, $maxvalname, $maxvaldata, $secdesclen,$lastwritetime) ($class, $classsz, $reserved, $numsubkeys,$maxsubkey, $maxclass, $values, $maxvalname, $maxvaldata, $secdesclen,$lastwritetime) = $obj->QueryKey() Get info about the current key. Win32::Registry | Base objects | Methods and functions | Constants and Variables QueryType $type_id = $obj->QueryType("value name") $obj->QueryType("value name",$type_id) This method gets the type of a value in the current key or in some subkey. GetType Win32::Registry | Base objects | Methods and functions | Constants and Variables QueryValue $value = $obj->QueryValue("subkey name") $obj->QueryValue("subkey name",$value) This method gets the content of the default value in the specified subkey. It's primarily for compatibility with Win3x (and with the original Win32::Registry). You should use method GetValue, GetValueEx or QueryValueEx to get the values in the current key. Win32::Registry | Base objects | Methods and functions | Constants and Variables QueryValueEx $obj->QueryValueEx("value name", $type, $value); GetValue, but returns a value in the current keys, instead of the default value in a subkey. In list context returns a list containing the name, type an...