第一步,建立一個(gè)CPP的DLL工程,然后寫(xiě)如下代碼,生成DLL
代碼如下:
#include <stdio.h>
#define DLLEXPORT extern "C" __declspec(dllexport)
DLLEXPORT int __stdcall hello()
{
printf("Hello world!/n");
return 0;
}
第二步,編寫(xiě)一個(gè) python 文件:
代碼如下:
# coding: utf-8
import os
import ctypes
CUR_PATH = os.path.dirname(__file__)
if __name__ == '__main__':
print 'starting...'
dll = ctypes.WinDLL(os.path.join(CUR_PATH, 'hello.dll'))
dll.hello()
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注