tags:

views:

559

answers:

2

Hi,

We have a Perl program that ran well on all Windows platforms so far.

When we tried it on the newly released Windows Server 2008 R2, it stopped working. Investigation revealed that the problem is that calls to read registry values using TieRegistry returned undefined values.

Is this a known problem? Did anyone run into a problem accessing the registry on Windows Server 2008 R2 using TieRegistry? I'm running the program as administrator, so I don't think it is permission problems. The program works great and read the registry correctly on Windows 7 and Vista.

A sample script I wrote to access the registry also fail:

use Win32::TieRegistry(Delimiter=>'\\');
my $reg = "HKEY_LOCAL_MACHINE\\SOFTWARE\\TEST\\Value1";
my $val = $Registry->{$reg};
print "val: ".$val."\n";

Any help would be appreciated.

Thanks, splintor

A: 

I found the source of my problem.

In order to make TieRegistry work well on 64-bit Windows, and access the correct registry hive, we used the solution suggested by Tony B. Okusanya (also quoted here). However, this solution adds both KEY_WOW64_64KEY and KEY_WOW64_32KEY to the access parameter, which is not logical – either you want to access the 64-bit registry and use KEY_WOW64_64KEY or you want the 32-bit registry and use KEY_WOW64_32KEY. Using both doesn’t really make any sense.

Nevertheless, in previous versions of Windows, as well as Windows 7, it seems that when RegOpenKeyEx notices that the KEY_WOW64_64KEY flag is set in the access parameter, it uses the 64-bit registry, and ignores the KEY_WOW64_32KEY flag. Windows Server 2008 R2, on the other hand, doesn’t ignore the KEY_WOW64_32KEY flag, and if both flags are set, opening the registry key fail, and Win32API::Registry.regLastError returns the error The parameter is incorrect.

Removing |KEY_WOW64_32KEY from our changed TieRegistry.pm solved the problem and caused our application to work again.

Regards,

splintor

splintor
A: 

hi

can you be so kind and let me see a small working testscript?

I've the problem that my script doesn't work on windows server 2008 R2 -> "The system could not find the environment option that was entered"

I think I've patched TieRegistry.pm correctly.

It doesn't work with KEY_WOW64_64KEY nor with KEY_WOW64_32KEY nor with both keys. thx. juergen

juergen
I'm sorry, but I no longer work in this project, and can't provide a working source.
splintor