Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 Python Ctypes加载库_Visual Studio 2010_Dll_Python 2.7_Ctypes_Loadlibrary - Fatal编程技术网

Visual studio 2010 Python Ctypes加载库

Visual studio 2010 Python Ctypes加载库,visual-studio-2010,dll,python-2.7,ctypes,loadlibrary,Visual Studio 2010,Dll,Python 2.7,Ctypes,Loadlibrary,我正在使用Windows7 64位计算机。我安装了Visual studio 2010并开发了一个简单的win32 dll来添加2个数字。。dll已经创建,我使用了一个测试应用程序来测试dll,它运行良好 现在我编写python脚本(如下所示)来使用这个库。但是我得到了下面的错误消息 Traceback (most recent call last): File "C:\Users\sbritto\Documents\Visual Studio 2008\Projects\MathFuncs

我正在使用Windows7 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
请尽快告诉我


提前感谢

如果您尝试使用为32位机器编译的Python解释器打开64位DLL,则会出现此错误,反之亦然。因此,如果这是一个64位DLL,您需要确保您正在运行一个64位Python。

您是将64位Python与32位DLL一起使用,还是相反?如果是,请不要:)
import ctypes
from ctypes import *

#lib = cdll.LoadLibrary("MathFuncsDll.dll")
lib = ctypes.WinDLL('MathFuncsDll.dll',use_last_error=True)
print lib