How do I make the 32-bit Perl read the 64-bit Windows registry?
- by Santhosh
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?