I am using ctypes to load a 64-bit Windows DLL into a 64-bit Python 3.6.2 environment, but Python complains that the DLL is not a 32-bit DLL. This is all 64-bit, so I don't know why it expects a 32-bit DLL. This same error message appears in Visual Studio 2017 and in PyCharm 2017.1.5.
Here is the problem code:
ThisDLL = ctypes.WinDLL(r"C:\Temp2\Test_Project\Std_Math_Formulas.dll") Here are the error messages:
File "C:\Project Backups\Python Projects - PyCharm\Test_DLL\Main_Entry.py", line 73, in CTypes_Test_02 ThisDLL = ctypes.WinDLL(r"C:\Temp2\Test_Project\Std_Math_Formulas.dll") File "C:\Program Files\Python36\lib\ctypes\__init__.py", line 348, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 is not a valid Win32 application I have researched this at length, and the answers all apply to a mixed 32-bit to 64-bit situation -- 32-bit DLL in 64-bit environment or 64-bit DLL in 32-bit environment. Here they both environment and DLL are 64-bit.
I know that Windows 32-bit DLLs use the stdcall calling convention and 64-bit uses the fastcall convention, but ctypes should be able to load a 64-bit DLL.
import platform; print(platform.architecture())?