[Tutor] python ctypes dll issue

Mark Tolonen metolone+gmane at gmail.com
Mon May 9 17:19:00 CEST 2011


"mammar" <mammar at gmail.com> wrote in message 
news:BANLkTin90dmfRkBu5O=dZ-p36fp3NL_Uww at mail.gmail.com...
> Hi All,
>
>
> I have created a DLL with the following function exported in it
>
> int myFunction(char *id, char *name);
>
>
> Below is the python code to load the dll and call myFunction
>
>
> from ctypes import *
>
> # Load DLL into memory
> mydll= windll.LoadLibrary("my.dll")
>
> id = create_string_buffer("030725002")
> name = create_string_buffer("mammar")
>
> print mydll.myFunction(id, name)
>
>
>
> But when i run the above code i am getting error dialog box with following
> info
>
> Debug Assertion Failed!
>
> Program: C:\Python27\pythonw.exe
> file: fread.c
> line: 93
>
> Expression: (buffer != NULL)
>
>
> Whats the problem? Any idea?

"windll" requires the function called to be __stdcall calling convention. 
The default is normally __cdecl.  Try "cdll" instead.

-Mark




More information about the Tutor mailing list