views:

710

answers:

3

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?

+2  A: 

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.

Hans Passant
A: 

Santhosh, Did you find a solution? Do you mind sharing?

bullcity, Actually i did not go for the Win32 API. Did some trials and was unsuccessful. But since all i wanted was to read the registry value of 64 bit hive, i just wrote a batch file and invoked that batch file from c:\windows\system32\cmd.exe - this would run the batch file under 64 bit context so i can get to the 64 bit registry hive. If on the otherhand i wanted the 32 bit registry hive, i would execute the same batch file using c:\windows\syswow64\cmd.exe.
Santhosh
Thanks for the response. This is a tricky problem for me; executing a batch file is def. possible, it just adds additional complexity to an already complex routine I have for querying the status of a testing machine. I may just try a few Win32 API trials myself. If I figure anything out, I'll be sure to follow up with you.
+1  A: 

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.

Ajith Antony