【发布时间】:2013-01-31 09:04:13
【问题描述】:
我使用的是 Windows 7 64 位机器。我安装了 Visual Studio 2010 并开发了一个简单的 win32 dll 来添加 2 个数字。创建了 dll,我使用测试应用程序测试了 dll,它工作正常。..
现在我编写 python 脚本(如下所示)来使用这个库。但我收到以下错误消息。
Traceback (most recent call last):
File "C:\Users\sbritto\Documents\Visual Studio 2008\Projects\MathFuncsDll\Debug\MathFuncs.py", line 5, in <module>
lib = ctypes.WinDLL('MathFuncsDll.dll',use_last_error=True)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
Python 脚本
import ctypes
from ctypes import *
#lib = cdll.LoadLibrary("MathFuncsDll.dll")
lib = ctypes.WinDLL('MathFuncsDll.dll',use_last_error=True)
print lib
请尽快告诉我。
提前致谢
【问题讨论】:
-
您是否使用 64 位 Python 和 32 位 DLL,反之亦然?如果是这样,请不要:)
标签: visual-studio-2010 dll python-2.7 ctypes loadlibrary