I use a proprietary dll from Software Source (vbis5032.dll). I have successfully used it from Visual Basic 6, Fujitsu Cobol and from Perl. I would now like to use it from Python.
The following is the C++ prototype for one of the functions: short FAR PASCAL VmxOpen(BSTR *Filespec, LPSHORT lpLocatorSize, LPSHORT lpOmode, LPHANDLE lphwmcb, BSTR *Password); The following is some Python code I put together: from ctypes import * from ctypes.util import * libc = cdll.msvcrt printf = libc.printf sprintf = libc.sprintf print "\nVB/ISAM testing:" fName = windll.oleaut32.SysAllocStringByteLen("s:\\msdb\\dcod\x00", 13) printf ("fName = \x22%slx22\n", fName) pw = windll.oleaut32.SysAllocStringByteLen("XYZ\x00", 4) printf ("pw = \x22%slx22\n", pw) CacheSize = c_long(0) OpenMode = c_long(3) vHandle = c_long(0) p_vHandle = pointer(vHandle) X = c_long(0) printf ("Before - X = %d, CacheSize = %d, OpenMode = %d, vHandle = %d \n", X, CacheSize, OpenMode, vHandle) print "Ready to call (Library = " + find_library("vbis5032") + ") ..." X = windll.vbis5032.VmxOpen(byref(fName), byref(CacheSize), byref(OpenMode), byref(vHandle), byref(pw)) printf ("After - X = %d, CacheSize = %d, OpenMode = %d, vHandle = %d \n", X, CacheSize, OpenMode, vHandle) exit(0) The following is the output from the Python code: VB/ISAM testing: fName = "s:\msdb\dcodlx22 pw = "XYZlx22 Before - X = 0, CacheSize = 0, OpenMode = 3, vHandle = 0 Ready to call (Library = C:\Windows\vbis5032.dll) ... Traceback (most recent call last): File "C:\temp\test3.py", line 19, in <module> X = windll.vbis5032.VmxOpen(byref(fName), byref(CacheSize), byref(OpenMode), byref(vHandle), byref(pw)) TypeError: byref() argument must be a ctypes instance, not 'int' I am neither a C++ nor a Python expert, but having already used this dll from other languages, I know this should be possible. I am sure it is just my lack of knowledge of Python. Can anyone assist with this? -- http://mail.python.org/mailman/listinfo/python-list