如何安装 32 位和 64 位版本的 COM DLL 和“自动选择"? [英] How do I install both 32-bit and 64-bit versions of a COM DLL and "auto-select"?

查看:28
本文介绍了如何安装 32 位和 64 位版本的 COM DLL 和“自动选择"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个可以在 32 位和 64 位下正常编译的 DLL(一个 COM 服务器),但该 DLL 对 32 位版本和 64 位版本使用相同的 CLSID 和 AppID.这可以吗,还是必须改变?

We've got a DLL (a COM server) that will compile fine in 32-bit and 64-bit, but the DLL uses the same CLSID and AppID for the 32-bit version and the 64-bit version. Is this OK or does this have to change?

我问这个是因为显然在 64 位机器上,我们不能同时注册 32 位版本和 64 位版本.如果 32 位客户端应用程序可以自动使用 32 位 DLL,并且 64 位客户端应用程序可以自动使用 64 位 DLL,那就太好了.

I'm asking this because apparently on a 64-bit machine, we can't register the 32-bit version and the 64-bit version together. It would be nice if 32-bit client applications could automatically use the 32-bit DLL, and 64-bit client applications could automatically use the 64-bit DLL.

在相关说明中,我们有客户端应用程序的源代码和 Visual Studio 2005 项目文件……我们如何编译同一应用程序的 32 位和 64 位版本?这是一个 C# 应用程序,它包含对我们的 COM 服务器 DLL 的引用,如下所示:

On a related note, we have the source code and Visual Studio 2005 project file for a client application ... how do we compile a 32-bit and 64-bit version of the same application? It's a C# application, and it includes a reference to our COM server DLL like this:

<代码><项目组><COMReference Include="ComServer">

{C1FADEA6-68FD-4F43-9FC2-0BC451FA5D53}

830<VersionMinor>0</VersionMinor>

<VersionMajor>830</VersionMajor> <VersionMinor>0</VersionMinor>

0<WrapperTool>tlbimp</WrapperTool><Isolated>False</Isolated>

<Lcid>0</Lcid> <WrapperTool>tlbimp</WrapperTool> <Isolated>False</Isolated>

<代码></ItemGroup>

</COMReference> </ItemGroup>

如果事实证明我们需要一个单独的 64 位 CLSID,我们如何使这个引用仅适用于 32 位配置"?在 Visual Studio 中?或者我们是否必须有具有相同源代码的单独项目:一个引用 32 位 DLL,另一个引用 64 位 DLL?

If it turns out that we need a separate CLSID for 64-bit, how do we make this reference "only for the 32-bit configuration" in Visual Studio? Or do we have to have separate projects with the same source code: one that refers to 32-bit DLL, and the other that refers to 64-bit DLL?

推荐答案

两个版本都可以(而且确实应该)对所有内容使用相同的 GUID.

Both versions can (and indeed should) use the same GUIDs for everything.

在 32 位机器上,您无法注册或使用 64 位 DLL,因此没有问题.64 位 DLL 根本不输入图片.

On a 32-bit machine you can't register or use the 64-bit DLL, so there's no problem there. The 64-bit DLL simply doesn't enter the picture.

在 64 位机器上,64 位 DLL 在 HKLM/Software/Classes/CLSID(等)中注册,32 位 DLL 在 HKLM/Software/Wow6432Node/Classes/CLSID 中注册.(我想知道你从哪里得到的关于你不能在 64 位机器上注册 32 位 DLL 的建议......)在 64 位机器上运行的 32 位客户端将在注册表中的正常位置查找,但操作系统会以静默方式将其重定向到 Wow6432Node 键.

On a 64-bit machine the 64-bit DLL gets registered in HKLM/Software/Classes/CLSID (etc.) and the 32-bit DLL gets registered in HKLM/Software/Wow6432Node/Classes/CLSID. (I wonder where you got the advice that you can't register the 32-bit DLL on a 64-bit machine...) A 32-bit client running on the 64-bit machine will look in the normal place in the registry, but the OS will silently redirect it to the Wow6432Node key instead.

这篇关于如何安装 32 位和 64 位版本的 COM DLL 和“自动选择"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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