The Win32::TieRegistry and Win32::Registry modules are great for this. I prefer
Win32::TieRegistry myself.
You will want to install it via PPM
C:\> PPM
PPM> install Win32-TieRegistry
If you run into problems because of a firewall or proxy server, do a search on the
ActveState site. Attached is a little tutorial I wrote for a friend. It's by no
means a comprehensive reference, but it works okay for beginners who just want to see
how the module works for the most common tasks.
-----Original Message-----
From: Waris Mirza [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 04, 2003 9:00 PM
To: [EMAIL PROTECTED]
Subject: Please Explain
Hi
I am trying to save (read / change / write) windows XP taskbar registry
values. Like show clock, always on top and same for desktop setting
How can I get registry settings, save it and change it again.
Can you please send me the source code.
Through which I can read and write taskbar values in registry/
Please help
Waris Mirza
#####################################################
## ##
## Win32-TieRegistry_Tutorial v1.1 ##
## written by Tim Johnson ##
## ##
#####################################################
#Welcome to the tutorial. This should give you a good
#enough idea of how to manipulate the Windows registry
#to perform most tasks. Let's get started by declaring
#our modules.
use strict; #always a good idea in general
use Win32::TieRegistry(Delimiter => "/");#So that we can use forward slashes
#A new Win32::TieRegistry object is automatically created
#called $Registry. $Registry is a hash reference[1]. Each
#key of the hash it points to is either another reference to
#another hash or a scalar which corresponds to a"value"(to
#use the registry term). This will make a little more
#sense after you've used it a while.
#Now that we've created the registry hashes, let's try
#working with what we've created. We can create a new
#object[1] that points to a specific part of the registry
#or we can just shoot for the part we want to change.
#For the purposes of making this easier to read, I'll make
#a new object.
my $IEKey = $Registry->{'HKEY_CURRENT_USER/Software/Microsoft/Internet
Explorer/Main/'};
#The arrow operator, the way it is used in this example, denotes that we are
#working with a hash reference, and not a key of %Registry. We now have
#an object that represents the exact key we want to work with. Now let's
#change the 'Start Page' value.
$IEKey->{'Start Page'} = "http://www.perl.org";
#Viola! Your start page has changed. Now let's try creating a new key.
$Registry->{'HKEY_CURRENT_USER/Software/Perl Beginners/'} = {};
#We've created a new, empty key. Now let's set the default value.
$Registry->{'HKEY_CURRENT_USER/Software/Perl Beginners//'} = "Camel";
#Notice that since the default value does not have a name, there
#are TWO slashes at the end of the key. With Win32::TieRegistry,
#If you want to resolve ambiguities about whether the item at the end
#is a registry key or registry value, you can (a)add a slash to the end
#to denote a key, or (b)add two slashes before the value, so our
#double-slash denotes a value with a zero-length name[2].
#For our next trick, lets create a new object for simplicity, and add
#a value to our new key.
my $BeginnerKey = $Registry->{'HKEY_CURRENT_USER/Software/Perl Beginners/'};
$BeginnerKey->{'TIMTOWTDI'} = "There Is More Than One Way To Do It";
#And for a variation on a theme, lets try a REG_DWORD value. This changes
#things a little because it is a binary value. We will have to specify
#both the value and the type like so, to avoid accidentally creating
#a string value.
$BeginnerKey->{'MyDWORD'} = ['0x0001',REG_DWORD];
#Finally, let's look at reading values. We are still treating each
#key as a hash reference, so we will have to dereference our hash to
#get the value.
my $KeyValue = $BeginnerKey->{'TIMTOWTDI'};
print "My new variable's value is: $KeyValue\n\n";
#That looks pretty clean, but what about getting all of the keys?
#If we dereference the hash, we can use the keys() function.
my @KeyArray = keys %{$BeginnerKey};
print "Here are the values in my registry key:\n";
foreach(@KeyArray){
if($_ eq '/'){
print " /(default)\n";
}else{
print " $_\n";
}
}
#There are more things you can do with this module, but I think that
#covers the basics. If you have any questions or comments, please post
#them back to the list and I'll try to answer them if I can.
#[1]Technically $Registry is a Win32::TieRegistry object. It is a tied
# hash that allows you to manipulate the hash and automagically
# cause changes to be made to the registry at the same time as changes
# are made to the hash. Just think of it as a hash reference if that
# seems confusing.
#[2]Win32::TieRegistry will cut you a little slack when it comes to
# calling keys and values, but it is always a good idea to add a slash
# to the end whenever you are working with a key. This reduces the
# possibility of accidentally creating a value when you meant to create
# a key, or vice versa.
#A QUICK NOTE ABOUT ACCESSING REMOTE COMPUTERS
#=============================================
#You can easily change these examples to manipulate a remote computer's
#registry. Simply add two slashes and the computername to the beginning
#like this:
#
#$Registry->{"//$computer/HKEY_LOCAL_MACHINE/SOFTWARE"}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]