我可以在 64 位 python 中使用 32 位 dll 或 exe 吗? [英] Can I use 32bit dll or exe in 64bit python?
问题描述
当我在32位python中使用CDLL调用32位dll时,效果很好.但是很遗憾我的64位win7 os只安装了64位python,调用的时候就变成了:这不是一个有效的win32应用!
When I use CDLL to call 32bit dll in 32bit python, it works well. But unfortunatelly in my 64bit win7 os only installs 64bit python, when calling it turns: it is not a effective win32 app!
我可以在 64 位 python 中使用 32 位 dll 或 exe 吗?或者我必须安装 32 位 python?
Can I use 32bit dll or exe in 64bit python? Or I have to install 32bit python instead?
推荐答案
64 位 EXE 无法加载 32 位 DLL.(反之亦然:32 位 EXE 无法加载 64 位 DLL.)毕竟,他们无法就指针的大小达成一致——如果 EXE 分配的内存超过 4GB 边界并想通过它会发生什么指向 32 位 DLL 的指针?
64-bit EXEs cannot load 32-bit DLLs. (And vice versa: 32-bit EXEs cannot load 64-bit DLLs.) After all, they can't agree on the size of a pointer -- what would happen if the EXE allocated memory above the 4GB boundary and wanted to pass that pointer to the 32-bit DLL?
您必须:
- 制作 64 位版本的 DLL;
- 使用 32 位版本的 Python;或
- 在单独的(32 位)EXE 中托管 DLL,并使用某种形式的进程间通信从您的 64 位 Python 进程与其对话.
这篇关于我可以在 64 位 python 中使用 32 位 dll 或 exe 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!