On Mar 20, 4:55 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 3:42 PM, Craig <[EMAIL PROTECTED]> wrote: > > > On Mar 20, 2:38 pm, Craig <[EMAIL PROTECTED]> wrote: > > > On Mar 20, 2:29 pm, sturlamolden <[EMAIL PROTECTED]> wrote: > > > > > On 20 Mar, 19:09, Craig <[EMAIL PROTECTED]> wrote: > > > > > The culprit i here: > > > > > > Before - X = 0, CacheSize = 0, OpenMode = 3, vHandle = 0 > > > > > This binds these names to Python ints, but byref expects C types. > > > > > Also observe that CacheSize and OpenMode should be c_short. > > > > I changed CacheSize and OpenMode to c_short, and commented out that > > > line producing the "Before" message, and the output is the same. > > > > Further "tinkering" revealed that it is the byref on the fName and pw > > > that are causing the error. > > > > The entire problem appears to be around the production of a BSTR and > > > the passing of pointers (byref) to the BSTR. > > > Can anyone shed some light on how to work with BSTR's? > > Since you didn't tell ctypes about the function signature, it assumes > it returns int and gives you a python int. Provide a function > signature (c_void_p should work for BSTR) for both functions and you > should have an easier time of it. > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list
Thanks Chris. I changed X to a c_short also, and modified the example as suggested: X = c_short(0) X = windll.vbis5032.VmxOpen(byref(c_void_p(fName)), byref(CacheSize), byref(OpenMode), byref(vHandle), byref(c_void_p(pw))) printf ("After - X = %d, CacheSize = %d, OpenMode = %d, vHandle = %d \n", X, CacheSize, OpenMode, vHandle) And, this is what printed: After - X = 4325376, CacheSize = 0, OpenMode = 3, vHandle = 17586736 The printf shows that the values of X and vHandle have changed, but I am not sure it is working properly as X should be a MUCH smaller number (< 256). I would have expected a 0 (VIS_OK), 13 (VIS_DOS_ERROR) or 14(VIS_DISK_ERROR) if it had worked. Next, I changed: fName = windll.oleaut32.SysAllocStringByteLen("u:\\msdb\\dcod\x00", 13) so that I knew it would not find the file, and got: After - X = 2555917, CacheSize = 0, OpenMode = 3, vHandle = 0 The vHandle staying 0 tells me that it did not find the file, but the value of X seems random. Based on the original C prototype, what am I doing wrong so that the return from the call to vbis5032 is not "usable"? -- http://mail.python.org/mailman/listinfo/python-list