Arrays and CTYPE

Chris Rebert clp2 at rebertia.com
Tue Sep 21 00:59:31 CEST 2010


On Mon, Sep 20, 2010 at 3:47 PM, Glenn Pringle <glenn.pringle at gmail.com> wrote:
> Ok. I ran into a problem here. I have been dabbling with Python and I
> thought that this would be a good exercise but I got stuck.
>
> I have a DLL and one of the functions(getState) in that DLL returns an
> array. I'm having a hard time getting access to the contents of that
> array.
>
> Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>>>> import ctypes
>>>> hold = ctypes.CDLL('Dinamap.dll')
>>>> print hold.checkReadiness()
> 1
>>>> print hold.getBufferLength()
> 1400
>>>> print hold.resetMonitor()
> 1
>>>> print hold.getState()
> 42607516
>>>>
>
> Would greatly appreciate if somebody points me in the right direction.

Set hold.getState.restype appropriately. Read the fine docs:
http://docs.python.org/library/ctypes.html#return-types
http://docs.python.org/library/ctypes.html#fundamental-data-types

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list