Need help calling a proprietary C DLL from Python
Chris Mellon
arkanes at gmail.com
Thu Mar 20 16:55:09 EDT 2008
On Thu, Mar 20, 2008 at 3:42 PM, Craig <craigm3604 at gmail.com> wrote:
>
> On Mar 20, 2:38 pm, Craig <craigm3... at gmail.com> wrote:
> > On Mar 20, 2:29 pm, sturlamolden <sturlamol... at yahoo.no> wrote:
> >
> > > On 20 Mar, 19:09, Craig <craigm3... at gmail.com> 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
>
More information about the Python-list
mailing list