如何让 32 位 Perl 读取 64 位 Windows 注册表? [英] How do I make the 32-bit Perl read the 64-bit Windows registry?

查看:29
本文介绍了如何让 32 位 Perl 读取 64 位 Windows 注册表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 32 位的 perl 安装程序.使用它,我需要能够安装和卸载 32 位和 64 位应用程序.

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

安装 32 位和 64 位没问题.卸载32位也可以.

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

但是,我在卸载 64 位应用程序时遇到问题.

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

应用程序只知道应用程序的名称,如控制面板中的添加删除程序中所示.例如,它可能是Winzip 14.0",它是 Winzip 的显示名称.

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.

我使用以下方法进行卸载:我遍历到 HKLM/Software/Microsoft/Windows/CurrentVersion/Uninstall 并解析那里的密钥以查看 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

如果应用程序是 64 位安装,则卸载信息将驻留在 HKLM/Software/Microsoft/Windows/CurrentVersion/Uninstall.

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

但是上面给出的 perl 安装程序代码试图从HKLM/Software/WOW6432Node/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.

那么如何让 Perl 代码在 32 位进程中运行以读取在 64 位配置单元中找到的注册表值?我知道采用 KEY_WOW64_64KEY 参数的 RegOpenKey() API.但由于它是一个 Windows API,我不知道这是否会有所帮助.即便如此,还有其他选择吗?

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?

推荐答案

是的,您必须使用 KEY_WOW64_64KEY,对于 32 位进程没有其他解决方法.从 这个网页来看,似乎可以直接从 Perl 调用 Win32 API/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.

这篇关于如何让 32 位 Perl 读取 64 位 Windows 注册表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆