Win32::Registry

This 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 main:: namespace, and each key that you open or create is accessed via one of these root objects. The four top-level objects are:

$HKEY_CLASSES_ROOT 
$HKEY_CURRENT_USER 
$HKEY_LOCAL_MACHINE 
$HKEY_USERS

If you are outside of the main (default) namespace, you should package declare the keys, i.e., $main::HKEY_USERS.

The Open method creates new key objects for subtrees or subkeys under another open key object. Initially, a new key is opened from one of the main key objects, for example:

use Win32::Registry;
$p = "SOFTWARE\Microsoft\Windows NT\CurrentVersion";
$HKEY_LOCAL_MACHINE->Open($p, $CurrVer) || die "Open $!";

This example creates a key object $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 ...

Get Perl in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.