Python COM and Delphi callback

Larry Bates larry.bates at websafe.com
Wed May 2 18:41:39 EDT 2007


I have a Python COM object working.  I want to pass to it
a Delphi callback function (showing progress) that I can
call periodically.  I've Googled until I'm cross-eyed and
I'm getting nowhere.  Anybody out there that could give
me a push in the right direction.

I tried passing pointer to my callback function using
@ operator in Delph, but when I compile Delphi complains.

Here is a snip of my Delphi code:

function Callback(total: integer; position: integer): boolean; stdcall;
begin
  WriteLn('In Callback, total=' + IntToStr(total) +
          ' position=' + IntToStr(position));
  result := True;
end;

.
. In program
.
//
// Set callback function in wsAPI to be called for each block
// that is uploaded.  oC contains instance of COM object and
// works perfectly.  oC has a method called WSset_callback that
// expects a callback function as an argument.  I have the
// callback working perfectly in pure-Python code.
//
oC.WSset_callback(@Callback);

When I compile I get:

[Pascal Error] wsAPICOM.dpr(151) E2281 Type not allowed in Variant
Dispatch call.

Thanks in advance for any assistance.

Regards,
Larry



More information about the Python-list mailing list