Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem reading Registry Key Value using Win32::TieRegistry

Status
Not open for further replies.

mockler

Programmer
Aug 16, 2002
15
CA
Hello all.

I'm trying to read in a value of a registry key using the Win32::TieRegistry module. But I can't seem to get it to work. I even tried the exact examples given in the module information on CPan. Can anybody help? Is there something that I'm missing here?

Below is my script so far. It should be very simple (it if worked).

use Win32::TieRegistry;

$jvm_option_value = Registry->{"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Tips\\\\18"};

print ("The value in the registry is: $jvm_option_value \n");




Thanks in advance.
 
what do you mean can't get it to work? Are you getting an error meesage or a blank page or what?
 
When I run the little script it runs but there is no value for the $jvm_option_value variable. The output of the script is:

"The value in the registry is: "



So the script runs no problem but it isn't reading the value of the registry key. (There is a value for this key when I look through the registry.)
 
I read that section and I saw the part about creating a tied hash first. But then as you read on it says that you can use "$Registry" instead of using a tied hash. Which is what I did in the above script.

But just to make sure that is the case, I tried creating a tied hash (see my new script below), but I had the same results. The value of the key is not read. :(



use Win32::TieRegistry (TiedHash => '%RegHash');
$jvm_option_value = Registry->{"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Tips\\\\18"};

print ("The value in the registry is: $jvm_option_value \n");



I do appreciate your help though. Does the script work for you?
 
Why the 4 backslashes between Tips and 18? Shouldn't there just be 2?
 
Since it is running on windows you need two backslashes if you want just 1 in the string. And according to the Win32::TieRegistry documentation "\\" is appended to each key name, and "\\" is prepended to the value name.

Therefore there is one set of backslashes for the key name "Tips", and there is one set of backslashes for the value name "18". (I could have stated that the delimiter is "/" {by doing '$Registry->Delimiter("/");' ) to make it easier to read.. then the line could be:

$jvm_option_value = Registry->{"HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Explorer/Tips//18"};
 
I haven't tried to run any code, I just took a quick look at the documentation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top