How do I make the 32-bit Perl read the 64-bit Windows registry?

Posted by Santhosh on Stack Overflow See other posts from Stack Overflow or by Santhosh
Published on 2010-01-21T16:15:30Z Indexed on 2010/03/23 0:11 UTC
Read the original article Hit count: 670

Filed under:
|
|

I have a 32-bit perl installer. Using this I need to be able to install and uninstall both 32- and 64-bit applications.

Installing 32- and 64-bit is fine. Uninstalling 32-bit is also ok.

However, I have a problem while uninstalling 64-bit applications.

The application just knows the name of the application as seen in Add Remove programs in control panel. For instance it could be "Winzip 14.0" which is the display name for Winzip.

I use the following approach for uninstallation : I traverse to HKLM/Software/Microsoft/Windows/CurrentVersion/Uninstall and parse the keys present there to see if Winzip is matching. If so i get the uninstall string from there.

    my $register = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
    $HKEY_LOCAL_MACHINE->Open($register,$hKey)|| die $!;
    #Then parse all the nodes and fetch the uninstall string

If the application is a 64-bit installation, then the uninstallation information will reside in HKLM/Software/Microsoft/Windows/CurrentVersion/Uninstall.

However the above given perl installer code is trying to read from HKLM/Software/WOW6432Node/Microsoft/Windows/CurrentVersion/Uninstall
and it does not find the installation there.

So how do I make the Perl code running in a 32_bit process to read the registry value found in 64-bit hive? I am aware of the RegOpenKey() API that takes KEY_WOW64_64KEY parameter. But since it is a Windows API, I dont know if that will help. Even then, is there any other alternative?

© Stack Overflow or respective owner

Related posts about perl

Related posts about registry