COM object pointer cast

Simon Brunning simon at brunningonline.net
Mon Mar 27 18:23:09 CEST 2006


On 27 Mar 2006 00:19:09 -0800, Axel Bock <axel.bock.news at googlemail.com> wrote:
> I am fooling around with the Python-COM bridge, and I have a little
> question with that.
>
> In the component I am using is a method which will return an "Entry"
> object - basically. In truth it returns some object which inherits from
> entry, and I know which one, but - as said - the method will only
> return the IEntry interface pointer. Now I would like to cast that one
> to the one I need :) . Is there an easy way to do it, or do I have to
> use the QueryInterface-method to get what I want?

There's an easy way - use win32com.client.CastTo(). See the
convert_tracks.py script on this page -
<http://www.brunningonline.net/simon/blog/archives/001742.html> for an
example.

--
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list