ctypes on Windows question: How to access an array of uint32_t exported from a DLL?

pjfarley3 at earthlink.net pjfarley3 at earthlink.net
Mon Jun 7 21:47:44 EDT 2021


> -----Original Message-----
> From: Eryk Sun <eryksun at gmail.com>
> Sent: Monday, June 7, 2021 12:34 PM
> To: python-list at python.org
> Cc: pjfarley3 at earthlink.net
> Subject: Re: ctypes on Windows question: How to access an array of uint32_t
> exported from a DLL?
> 
> On 6/6/21, pjfarley3 at earthlink.net <pjfarley3 at earthlink.net> wrote:
> >
> > On a Windows 10 platform (python 3.8.9 and 3.9.5), how do I use ctypes
> > to access an array of uint32_t's exported from a DLL?
> > ...
> > __declspec(dllexport) extern uint32_t array_name[128];
> 
> A ctypes data type has an in_dll() method [1] that returns an instance of the type
> that references data in a shared library (DLL). It takes a CDLL instance for the
> shared library and the exported symbol name. For
> example:
> 
>     data = (ctypes.c_uint32 * 128).in_dll(library, "array_name")

Thanks for the help.  I just didn't see this kind of simple case demonstrated on the ctypes doc page.

I guess I am just a bit dense.  Mea culpa.  Anyway, thanks again.

Peter
--




More information about the Python-list mailing list