我可以在64位python中使用32位dll或exe吗? [英] Can I use 32bit dll or exe in 64bit python?
问题描述
当我使用CDLL在32位python中调用32位dll时,它运行良好。
但不幸的是,在我的64位win7操作系统中,它只能安装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!
我可以使用32位dll还是EXE在64位Python?还是我必须安装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;或
- 将DLL托管在单独的(32位)EXE中,并使用某种形式的进程间通信与您的64位Python进程进行通讯。
这篇关于我可以在64位python中使用32位dll或exe吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!