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?
Press SHIFT+F4 on your keyboard and select the components of the 64-bit registry values. Right-click one of them and select the "Properties" menu. In the "Edit Component Properties" dialog set the Condition field to VersionNT64. Tick the option 64-bit Component.
HKEY_CLASSES_ROOT Key - Win32 apps.
The default version of regedit.exe on a 64 bit Windows OS is the 64 bit version. The regedit executable located in C:\Windows\SysWOW64 is the 32 bit version, and the executable in C:\Windows is the 64 bit version.
The Wow6432Node registry entry indicates that you are running a 64-bit Windows version. The operating system uses this key to display a separate view of HKEY_LOCAL_MACHINE\SOFTWARE for 32-bit applications that run on 64-bit Windows versions.
Yes, you have to use KEY_WOW64_64KEY, there is no other workaround for a 32-bit process. Calling the Win32 API directly from Perl appears possible, judging from this web page.
You could also call the reg tool directly, instead of the batch file:
$WINDIR/system32/reg.exe
This is the default location for reg.exe when included with operating system.
$WINDIR/sysnative/reg.exe
This is the virtual location of the native 64-bit reg.exe when executed from a 32-bit process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With