OSError: [WinError 193] %1 不是有效的 Win32 应用程序。
解决方案:将X86改为X64重新生成dll
示例:
c++
// extern"C”c++中编译c格式的函数﹐如果用c语言编译就不需要
// declspec(dllexport)函数导出到库中
#include <stdio.h>
extern "C" __declspec(dllexport) void TestCtypes() {
printf("hello major!");
}
python
from ctypes import *
# 导入库windows中dl1后缀名不用加
lib = CDLL("testCtypesDll1.dll")
lib.Test()