COM object pointer cast

A

Axel Bock

Hi,

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?


Greetings & thanks in advance,

Axel.
 
S

Simon Brunning

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top