Python COM called from VB/Delphi

Jorge Mazzonelli jmazzonelli at gmail.com
Fri Mar 16 10:56:56 EDT 2007


Larry,

It's been a while since I coded something in VB or Delphi because I'm mostly
turn on Python ;)
so please excuse me any mistakes I can make  8I don't have neither VB or
Delphi installed on this computer)

For Delphi to use an OLE/COM Object it requires a TypeLibrary that explains
how to access to this COM Object. For this you can use Project-->Import
TypeLibrary. This will create automatically a .pas file with all the
declaratons needed so you can use the object from Delphi.
The Object exposed from python is from the point of view of Delphi simply a
COM object. So if you need help on implementing a COM client in Delphi I
suggest you to turn to the Delphi-related groups or do some google search
about it.
I found myself a simple tip about optional parameters and how they are
handle in Delphi, here:
http://blogs.teamb.com/CraigStuntz/archive/2005/07/01/UsingCOMOptionalParamsFromDelphi.aspx

On the VB side, you can see on the link below how to create a callback in VB
(it requires calling to the Windows API)
http://www.thevbzone.com/secrets.htm#AddressOf

But if I understand you well, you need to make the client aware that
something has change (the progress of download for example or the end of the
downloading) I think that the simplest way may be to raise events from you
python code. This way the events are treat naturally in VB. For an example
on how to raise events from you python code, you can look at the sample demo
in win32com/demos/connect.py (implements client and server) or in
win32com/server/connect.py (for server implementation. The demo server
inherits from this one)
Last, Mark Hammond respond while ago about COM Server & Events:
http://mail.python.org/pipermail/python-win32/2004-September/002386.html, I
don't know if there are changes...

Regards,

     Jorge


On 3/15/07, Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:
>
> En Wed, 14 Mar 2007 21:17:12 -0300, Larry Bates <lbates at websafe.com>
> escribió:
>
> > I have a rather large Python class that I've converted to
> > a COM object.  I can dispatch (using either Python or VB)
> > and call the methods perfectly.  Now a new client wants
> > to call it from Delphi.  Can anyone out there give me
> > any pointers on how that would be done.  Are there any
> > "gotchas" about the way arguments or return values
> > would need to be different for Delphi.  I have NO Delphi
> > experience so I'm completely lost.
>
> The same as he would do for any other COM object. There are tools in
> Delphi for building automatically the needed Delphi declarations
> (interfases, classes, methods, constants... similar to what makepy does
> for Python).
> All OLE types work fine. (Variants are a bit hard to process, yes, but it
> can be done)
>
> > Secondly, I need a callback function in VB (progress
> > meter) that I can pass to Python COM object to show
>
> Sorry, I try to stay away of VB as far as possible :)
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070316/ad6300cb/attachment.html>


More information about the Python-list mailing list