Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 962
Santhosh Avatar asked Jan 21 '10 16:01

Santhosh


People also ask

How do I change my registry from 32-bit to 64-bit?

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.

Which key is used by 32-bit applications on a 64-bit Windows OS?

HKEY_CLASSES_ROOT Key - Win32 apps.

Where is the 64-bit registry?

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.

What is WOW6432Node in Windows registry?

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.


2 Answers

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.

like image 75
Hans Passant Avatar answered Oct 02 '22 01:10

Hans Passant


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.

like image 41
Ajith Antony Avatar answered Oct 02 '22 01:10

Ajith Antony