为什么 Regasm 将 ProgId 放入 HKEY_CURRENT_USER? [英] Why does Regasm put ProgId into HKEY_CURRENT_USER?

查看:20
本文介绍了为什么 Regasm 将 ProgId 放入 HKEY_CURRENT_USER?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在两台虚拟机上(Wix)安装我的软件.一个是 Windows XP SP2,另一个是 Windows XP SP1.他们都没有使用域,并且他们都拥有具有管理员权限的本地用户 Administrator.

I have two Virtual Machines that I wish to (Wix) install my software onto. One is Windows XP SP2 and another is Windows XP SP1. Neither of them use domains, and both of them have the local user Administrator with admin privileges.

运行 RegAsm.exe 在装有 SP3 的机器上注册 MyApp.dll 会将我的 ProgId 放入文件夹中:

Running RegAsm.exe to register MyApp.dll on the machine with SP3 puts my ProgId in the folders:

HKEY_CLASSES_ROOTMyAppProgId

HKEY_CLASSES_ROOTMyAppProgId

HKEY_LOCAL_MACHINESoftwareClassesMyAppProgId

HKEY_LOCAL_MACHINESoftwareClassesMyAppProgId

而在 SP2 机器上运行它会将其放入文件夹中:

whereas running it on the SP2 machine puts it in the folders:

HKEY_CLASSES_ROOTMyAppProgId

HKEY_CLASSES_ROOTMyAppProgId

HKEY_CURRENT_USERSoftwareClassesMyAppProgId

HKEY_CURRENT_USERSoftwareClassesMyAppProgId

我在尝试从服务加载 MyApp.dll 时发现了这一点.从 RegAsm.exe 和 Heat.exe 生成的注册表文件似乎都在更新 HKEY_CLASSES_ROOT.

I found this while trying to load MyApp.dll from a service. The registry file generated from RegAsm.exe and also Heat.exe both appear to be updating HKEY_CLASSES_ROOT.

有谁知道这是什么原因造成的?

Does anyone know what could cause this?

我最终通过直接写入 HKEY_LOCAL_MACHINE 而不是 HKCR 来解决这个问题 - 这涉及手动编辑生成的 .reg 文件或 .wxs 文件.

I ended up getting around this by writing directly to HKEY_LOCAL_MACHINE instead of HKCR - this involved manually editing a generated .reg file or .wxs file.

推荐答案

在旧设置上 HKEY_LOCAL_MACHINE 对普通用户是可写的,在较新的 Windows(例如 Windows 7)上则不是.可能取决于配置、用户帐户类型等.

On older setups HKEY_LOCAL_MACHINE is writable for a normal user, on newer Windows's (e.g. Windows 7) it is not. Might depend on configuration, user account type etc.

已注册的类转到 HKEY_LOCAL_MACHINESOFTWAREClasses(有时可写,如前所述)或 HKEY_CURRENT_USERSoftwareClasses(始终可写).两者都有效.第一种情况是压倒性的默认值.

Registered classes go either to HKEY_LOCAL_MACHINESOFTWAREClasses (sometimes writable, as mentioned) or HKEY_CURRENT_USERSoftwareClasses (always writable). Both work. The first case is the overwhelming default.

HKEY_CLASSES_ROOT其实只是一个view,合并了上述分支的内容.这就是为什么您会在两个不同的位置看到它.

HKEY_CLASSES_ROOT is actually only a view, which merges the contents of the aforementioned branches. This is why you see it under two different locations.

RegAsm 似乎足够聪明,可以检测 HKLM 的只读条件并自动选择 HKCU.或者您的虚拟机之间存在一些不同的配置设置.

RegAsm seems to be smart enough to detect the readonly condition of HKLM and automagically picks HKCU instead. Or there is some configuration setting which differs between your VMs.

主要区别在于,在第二种情况下,dll 只能在您注册它的用户帐户下使用.您的服务可能在另一个帐户下运行,因此它无法在第二台机器上加载 dll.

The main difference is that in the second case, the dll is only usable under the user account where you registered it. Your service probably runs under another account, so it cannot load the dll on the 2nd machine.

这篇关于为什么 Regasm 将 ProgId 放入 HKEY_CURRENT_USER?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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