how to call this dll in python

Shark ysystudio at gmail.com
Mon Nov 3 21:52:27 EST 2008


On Nov 3, 4:22 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> Shark schrieb:
>
> > I have a windows dll1.dll with a export function:
>
> > int f1(char filename,char **buf,int *bufLen)
> > {
> > int len;
> > //got the length of file anyway,such as 100
> > len = 100;//len = getLen(filename);
> > *buf = (char*)calloc(100);
> > *bufLen = len;
> > return 0;
> > }
>
> > then how can I call the f1 function with python.
> > thanks for your response.
>
> If the above is *really* what you want to access from python, you
> shouldn't bother & write it new in python itself. You could either use
>
> bufLen = len(open(filename).read())
>
> or make a os.stat-call.
>
> If it serves only as a rather ugly illustrative example, then you should
> investigate the ctypes-module of python, which is made for accessing
> arbitrary dlls from python.
>
> Diez

Yes,the function is rather ugly, but how can python get the memory
alloced by a dll through the dll function's parameter.
I am facing the problem in my project, I try ctypes all over, but can
not get the correct solution.



More information about the Python-list mailing list