Two COM Questions: QueryInterface, and Callback Inheritance
Christopher Paulicka
cpaulicka at 8cs.com
Tue Jul 25 17:14:26 EDT 2000
Hello,
I am using PythonWin, and the win32com extension. Using genpy, I have made
class wrappers for the appropriated type library.
QUESTION ONE:
How to QueryInterface for a new dispatch interface?
For example:
>>> import win32com.client
>>> d = Dispatch("MyCoolThing.App")
>>> s = d.GetOtherThing()
# Unfortunately, s is of class IMyInterface, and I want it to
# be for class IMyInterface2.
# The class exists in the genpy.
# How do I do the following type of thing?
>>> s2 = s.QueryInterface("IMyInterface2")
# The above does not work. Heh. Neither does...
>>> s2 = s.QueryInterface(IMyInterface2.CLSID)
# Is there a trivial way to do it?
QUESTION TWO:
How to subclass a class based on Dispatch? Can it work at all?
For example:
>>> import win32com.client
>>> d = Dispatch("MyCoolThing.App")
>>> s = d.GetOtherThing()
# s has a method, called SetCallback(), that takes a
# Dispatch interface to IThingCallback. There is a class in my
# genpy module called IThingCallback.
# How can I do the following? (Is it possible somehow?)
>>> class MyCallback(IThingCallback):
def Go(self, data):
print data
>>> c = MyCallback()
>>> s.SetCallback(c)
Thanks for all your help,
Christopher Paulicka
More information about the Python-list
mailing list