Calling C Function Pointers from Python

Neil Hodgson neilh at scintilla.org
Sun Jul 30 08:47:23 EDT 2000


> >    Here is a sequence of calls:
> >
> > import calldll
> > kernel32 = calldll.load_library('kernel32.dll')
> > Beep = calldll.get_proc_address(kernel32, "Beep")
> > ret = calldll.call_foreign_function(Beep,'ll','l',(1000,500))
> >
> >    Neil
>
> Thx. Can you (additionally) explain the meaning of 'll' and 'l' and give
an
> example where I receive a return value (a double for example)?

   The second argument, "ll" in this case is the shape of the arguments (two
long ints in the example) and is defined in the "Extending and Embedding..."
document. The third argument is the shape of the return value, a long int
here. The last argument is a tuple contining the arguments to the called
function. The example code is already receiving a return value indicating
whether the Beep succeeded. The readme.txt says
"calldll.call_foreign_function does not yet support returning 64-bit
quantities (like C doubles)".

   Neil






More information about the Python-list mailing list