OSError: [WinError 193] %1 不是有效的 Win32 应用程序。
![OSError: [WinError 193] %1 不是有效的 Win32 应用程序。_python](https://file.cfanz.cn/uploads/png/2022/03/30/9/a1GZaHS1MM.png)
解决方案:将X86改为X64重新生成dll
![OSError: [WinError 193] %1 不是有效的 Win32 应用程序。_c++_02](https://file.cfanz.cn/uploads/png/2022/03/30/9/JFQYX0985X.png)
示例:
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()









