It seems the function is using stdcall
instead of the cdecl
calling convention, i.e. use ctypes.WinDLL
instead of ctypes.CDLL
. Also, it wants a pointer to a memory location where it can store the handle, but you passed it a NULL
pointer. Instead pass it a reference to a wintypes.HANDLE
.
from ctypes import *
from ctypes.wintypes import *
ailt_lib = WinDLL("HVDAILT")
load_camera = ailt_lib.BeginHVDevice
load_camera.restype = c_int
load_camera.argtypes = [c_int, POINTER(HANDLE)]
def initDev(res=(800,600)):
cam_int = 1
cam_handle = HANDLE()
cam_stat = load_camera(cam_int, byref(cam_handle))
print 'cam_stat:', cam_stat
print 'cam_handle:', cam_handle
return cam_handle