代码如下:
#define DLLEXPORT extern "C" __declspec(dllexport)
DLLEXPORT int __stdcall hello()
{
printf("Hello world!\n");
return 0;
}
第二步,编写一个 python 文件:
代码如下:
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()