Calling C Function Pointers from Python

Neil Hodgson neilh at scintilla.org
Sun Jul 30 08:07:59 EDT 2000


> Can somebody tell me, how a dll call from Python works on principal? Let
us
> suppose I'd like to something like caldll. Where should I start. Which
> Python "primitives" have I to use?

   I can explain how to use calldll. If you want to know how to write your
own extensions then you should read the "Extending and Embedding the Python
Interpreter" document which is part of the standard documentation package
and should have been installed when you installed Python.

   calldll is a low level Python extension libary which contains functions
for creating buffers, loading DLLs, finding the address of functions within
the loaded DLLs, and calling the functions. On top of that is a higher level
windll module that makes it more convenient to call.

   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










More information about the Python-list mailing list