[Tutor] python ctypes dll issue

Alan Gauld alan.gauld at btinternet.com
Mon May 9 02:04:21 CEST 2011


"mammar" <mammar at gmail.com> wrote
> 
> I have created a DLL with the following function exported in it
> 
> int myFunction(char *id, char *name);
> 

This is a bit beyond beginner python, I suspect you will 
get a better response if you ask on the ctypes mailling 
list/forum.

> 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)
> 

> Program: C:\Python27\pythonw.exe
> file: fread.c
> line: 93
> 
> Expression: (buffer != NULL)

Looks like a problem in the C code but I don't know if thats 
the C in Python or the C in your DLL. I suspect we would need to see 
the C in the DLL function. 

You could add some print statements to find out where the 
error arises...

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list