在python中使用ctypes模塊調用dll庫中函數的方法
1.首先,在Python項目中引入ctypes模塊;
from ctypes import *
2.ctypes模塊引入后,在Python中加載dll庫;
Objdll = ctypes.WinDLL("dllpath")
3.最后,dll庫加載好后,通過以下方法即可調用dll庫中的函數;
strDllPath = sys.path[0] + str(os.sep) + "createguid.dll"
dll = CDLL(strDllPath)
b = dll.newGUID()
a = c_char_p(b)
except Exception, error:
print error
return ""
return a.value