且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在64位应用程序中使用32位dll?

更新时间:2021-08-24 02:43:59

不是直接不.

可能有一种解决方法从以下位置访问32位DLL: 64位代码 [
Not directly no.

There might be a workaround Accessing 32-bit DLLs from 64-bit code[^], but it comes with a lot of strings attached.

You might have to re-evaluate your reasons for wanting to convert to 64-bit.


感谢所有答复.根据答案,我想如果我看了足够长的时间,就会发现一些能让我轻松连接的东西.

我找到了.

它涉及注册表.


1.在HKey_Classes_Root/Wow6432Node/CLSID
下找到您的COM对象GUID.
2.找到后,添加新的REG_SZ(字符串)值.名称应为AppID,数据应与您刚刚搜索的相同的COM对象GUID

3.在HKey_Classes_Root/Wow6432Node/AppID下添加一个新密钥.新密钥的调用应与com对象GUID相同.
4.在刚添加的新键下,添加一个新的REG_SZ(字符串)值,并将其命名为DllSurrogate.将该值留空

5.如果尚不存在,请在HKey_Local_Machine/SoftwareClasses/AppID下创建一个新密钥.同样,新密钥应与COM对象的GUID相同.不需要在此键下添加任何值.
Thanks all who replied. Based on the answers, I thought if I looked long enough I''d find something that would allow me to connect easily.

I found it.

It involves the registry.


1. Locate your COM object GUID under the HKey_Classes_Root/Wow6432Node/CLSID

2. Once located add a new REG_SZ (string) Value. Name should be AppID and data should be the same COM object GUID you have just searched for

3. Add a new key under HKey_Classes_Root/Wow6432Node/AppID .The new key should be called the same as the com object GUID

4. Under the new key you just added, add a new REG_SZ (string) Value, and call it DllSurrogate. Leave the value empty

5. Create a new Key under HKey_Local_Machine/SoftwareClasses/AppID if it doesn''t already exist. Again the new key should be called the same as the COM object''s GUID. No values are necessary to be added under this key.


André的答案是正确的.事实是更基本的:您无法以任何方式以一种方式链接针对不同指令集体系结构的DLL,即使在运行时动态加载程序集并使用Reflection也不行.此外,代码可能会编译,但在运行时会崩溃.因此,只有一种解决方法:针对与机器架构兼容的不同指令集架构的代码只能在不同的进程中运行.结论很明显:唯一的协作方式是使用进程间通信(IPC).如果有人声称某些技术使用诸如COM之类的不同体系结构,则意味着IPC是在后台使用的.

—SA
The answer by André is correct. The fact is more basic: you cannot link DLLs targeted to different instruction-set achitectures in one process in any way, even dynamically loading an assembly during run-time and using Reflection. Moreover, the code may compile but crash during runtime. So, there is only one work-around: codes targeted to different instruction-set architectures compatible with machine architectures can only be run in different process. The conclusion is apparent here: the only way to collaborate is using Inter-Process Communications (IPC). If someone claims that some technology uses different architectures, such as COM, it means IPC is used under the hood.

—SA