ctypes and pointers

Diez B. Roggisch deets at nospam.web.de
Mon Apr 16 13:43:40 CEST 2007

per9000 wrote:

> [This might be a double posting, if it isn't my previous post was
> lost]
> Look up "restype" in the ctypes library - it sets the return type from
> a function. You may want to set it to c_void_p of something similar,
> instead of the default int.
> I made a similar discovery in my blog -
> http://www.pererikstrandberg.se/blog/index.cgi?page=PythonCansiCombo
> .
> This example loads the function find_root from the dll
> root_find_lib.dll into the variable "find". the restype of find is
> then set to a c_double. This means that the item returned from C is a
> C_double and not the default int.
>     root_find_lib = windll.LoadLibrary("root_find_lib.dll")
>     find = root_find_lib.find_root
>     find.restype = c_double

I found the solution to be 


where X is some ctypes.Structure


More information about the Python-list mailing list