in reply to TieRegistry and Windows Server 2008 R2

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 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
  • Comment on Re: TieRegistry and Windows Server 2008 R2

Replies are listed 'Best First'.
Re^2: TieRegistry and Windows Server 2008 R2
by Anonymous Monk on Jul 17, 2015 at 11:24 UTC

    I managed to use KEY_WOW64_32KEY and KEY_WOW64_64KEY without modifying Win32::TieRegistry:

    use Win32::TieRegistry qw(:KEY_); sub KEY_WOW64_64KEY {return 0x100;} sub KEY_WOW64_32KEY {return 0x200;} my $Reg32={}; my $Reg64={}; new Win32::TieRegistry("HKEY_LOCAL_MACHINE", { Delimiter=>'/', Access=> KEY_READ|KEY_WRITE|KEY_CREATE_SUB_KEY|KEY_WOW64_32KEY } ) ->Tie($Reg32); new Win32::TieRegistry("HKEY_LOCAL_MACHINE", { Delimiter=>'/', Access=> KEY_READ|KEY_WRITE|KEY_CREATE_SUB_KEY|KEY_WOW64_64KEY } ) ->Tie($Reg64);