Python使用ctypes库调用外部DLLri.docVIP

  • 14
  • 0
  • 约1.64千字
  • 约 9页
  • 2017-09-22 发布于宁夏
  • 举报
Python:使用ctypes库调用外部DLL Python之ctypes ctypes是Python的一个外部库,提供和C语言兼容的数据类型,可以很方便地调用C DLL中的函数。在Python2.5官方安装包都带有ctypes 1.1版。ctypes的官方文档在这里。 ctypes的使用非常简明,如调用cdecl方式的DLL只需这样: view sourceprint?1 from ctypes import *; 2 h=CDLL(msvcrt.dll) 3 h.printf(a=%d,b=%d,a+b=%d,1,2,1+2); 以上代码运行后输出 a=1,b=2,a+b=3。 加载库和普通函数的调用 官方API提供的库中有几个主要的函数: view sourceprint?01 //初始化 02 int DCSPCLIENTDLL InitInterface( const char *pCenterIP, const unsigned short nUpLinkSvrPort,const unsigned short nDownLinkSvrPort ); 03 04 //释放资源 05 int DCSPCLIENTDLL FiniInterface( void ); 06 07 //登录 08 int DCSPCLIENTD

文档评论(0)

1亿VIP精品文档

相关文档