Callback Python procedure from Delphi DLL

Diez B. Roggisch deets at nospam.web.de
Mon Jul 28 10:53:31 CEST 2008


durumdara at gmail.com wrote:

> Hi!
> 
> I have a component, and a tool in Delphi.
> I wanna call it from Python.
> 
> I can implement all things I need into a Delphi generated DLL.
> It is ok, I can use this DLL from Python, but the DLL procedure needs a
> callback procedure to return the partially output, and needs a python
> passed variable to check terminate/abort signal.
> 
> For example:
> procedure ProcessFiles(InputFiles : string; CallBackProc:
> ????????????????????????); export;
> begin
>     ....
>     CallBackProc(ProcessedFiles, Percentage, NeedToAbort);
>     if NeedToAbort then Exit;
>     ....
> end;
> 
> 
> def CallBackProc(ProcessedFiles, Percentage, NeedToAbort):
>     ...
> 
> But I don't know, how to call back this procedure, and how to pass
> variables.
> 
> The other way is a ActiveX.
> This time I don't load the DLL, I only construct the Delphi based Com
> Object, and I start the process.
> 
> But in this way I also don't know how to implement the callback, because
> the main code uses callback events, and I need to use too...
> 
> Thanks for every usable help!

ctypes allows to create callbacks. See the module-docs.

Diez



More information about the Python-list mailing list