Callback Python procedure from Delphi DLL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • durumdara@gmail.com

    Callback Python procedure from Delphi DLL

    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(In putFiles : string; CallBackProc:
    ??????????????? ?????????); export;
    begin
    ....
    CallBackProc(Pr ocessedFiles, Percentage, NeedToAbort);
    if NeedToAbort then Exit;
    ....
    end;


    def CallBackProc(Pr ocessedFiles, 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!
    dd


  • Diez B. Roggisch

    #2
    Re: Callback Python procedure from Delphi DLL

    durumdara@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(In putFiles : string; CallBackProc:
    ??????????????? ?????????); export;
    begin
    ....
    CallBackProc(Pr ocessedFiles, Percentage, NeedToAbort);
    if NeedToAbort then Exit;
    ....
    end;
    >
    >
    def CallBackProc(Pr ocessedFiles, 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

    Comment

    Working...