在 Windows7 上,regsvr32 不会写入 HKCR\CLSID
我使用 ATL 向导在 Visual Studio 2008 中创建了一个新的简单 COM 对象。该对象具有单个类和简单的方法。 ATL 向导确实为我的类生成了 .rgs 文件。
当我在 XP 计算机上运行 regsvr32 Simple.dll 时,该类已注册,信息显示在 HKCR\Simple.SimpleObject 和 HKCR\CLSID\{guid 中正如我所料。
然而,在我的 64 位 Windows 7 机器上,情况就不一样了。我以管理员身份运行 regsvr32,HKCR\Simple.SimpleObject
中的部分显示出来。但是 HKCR\CLSID 中的部分永远不会到达那里。因此我无法创建新实例。 (绝望中我在System32和SysWOW64中都尝试了regsvr32,效果相同。)
为什么不regsrv32
将数据放入HKCR\CLSID
?
I have created a new simple COM object in Visual Studio 2008 using the ATL-wizard. The object has a single class and simple methods. The ATL-wizard did generate .rgs
-files for my class.
When I run regsvr32 Simple.dll
on my XP machine the class is registered, information shows up in HKCR\Simple.SimpleObject
and in HKCR\CLSID\{guid}
as I expect.
However, on my 64bit Windows 7 machine it's not the same. I run regsvr32 as administrator the parts in HKCR\Simple.SimpleObject
show up. But the part in HKCR\CLSID
never gets there. And hence I cannot create new instances. (Being desperate I have tried both regsvr32 in System32 and in SysWOW64, same effect.)
Why dont regsrv32
put data into HKCR\CLSID
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
HKCR 是 HKLM\Software\Classes 的别名,但它并不显示所有内容。在 HKLM\Software\Wow6432Node\Classes\CLSID 中查找已注册的 {guid}。这是 c:\system32\syswow64\regsvr32.exe 写入它们的位置。
你确实提到你已经尝试过了。这确实是有问题的,你不能任意运行任一版本的 Regsvr32.exe 并注册相同的 DLL。 32 位 DLL 无法加载到 64 位进程中。换句话说,64位版本的Regsvr32.exe无法注册32位COM服务器。反之亦然。从这里无法猜测为什么您没有收到错误消息,唯一合理的解释是您实际上没有运行正确版本的 Regsvr32。
要真正调试此问题,请使用 SysInternals 的 ProcMon 实用程序。它的跟踪显示了 ATL 注册商如何在注册表中写入密钥。
HKCR is an alias for HKLM\Software\Classes but it doesn't show everything. Look in HKLM\Software\Wow6432Node\Classes\CLSID for the registered {guid}. Which is where c:\system32\syswow64\regsvr32.exe writes them.
You did mention that you already tried that. There's something really wrong with that, you cannot arbitrarily run either version of Regsvr32.exe and get the same DLL registered. A 32-bit DLL cannot be loaded in a 64-bit process. In other words, there's no way for the 64-bit version of Regsvr32.exe to register a 32-bit COM server. And the other way around. Why you didn't get an error message is unguessable from here, the only sane explanation is that you somehow didn't actually run the right version of Regsvr32.
To really debug this, use SysInternals' ProcMon utility. Its trace shows you how the ATL registrar is writing the keys in the registry.
32 位应用程序和组件被重定向到注册表的不同部分。如果您使用 64 位版本的 regedit 浏览注册表,您将无法在您期望的位置找到它。
因此,您的组件应在
HKEY_CLASSES_ROOT\Wow6432Node\CLSID
中注册自身。在此注册表路径中,它应该对所有 32 位应用程序可见。
另请参阅:
32bit applications and components are getting redirected to a different part of the registry. If you are browsing the registry with the 64bit version of regedit you will not find it at the location you expect.
Therefore your component should register itself in
HKEY_CLASSES_ROOT\Wow6432Node\CLSID
.In this registry path it should be visible to all 32bit applications.
See also:
我们刚刚遇到了类似的问题,Regsvr32 没有报告错误,但似乎没有任何内容写入注册表。
运行“以管理员身份”似乎可以解决问题。
We just had a similar issue here, Regsvr32 was not reporting an error, but nothing appeared to be written to the registry.
Running 'As Administrator' seemed to do the trick.