why ctypes+dll gives a strange result

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Nov 12 04:55:21 EST 2007


En Sun, 11 Nov 2007 08:21:25 -0300, oyster <lepto.python at gmail.com>  
escribi�:

> import ctypes
> mydll=ctypes.windll.LoadLibrary("mydll.dll")
>
> _TwoTimes=getattr(mydll,'TWOTIMES at 8')
> _TwoTimes.argtypes=[ctypes.c_double]
> def TwoTimes(i):
>         return _TwoTimes(i)
>
> in fact, twotimes function return double*2, but when I use
> print TwoTimes(10)
> in python, I get 2226880

I think you should declare the result type also, if it's not an integer.
_TwoTimes.restype=ctypes.c_double


-- 
Gabriel Genellina




More information about the Python-list mailing list