> Tim Roberts wrote:
> > ...
> > and get a generic COM exception when the RTD server tries to notify
> > Excel of data changes (from the trace collector):
> > ...
> > The COM Error is: "generic COM exception 0x80020009"
> >
> > The callpath that leads to the exception is:
> >
> >
> > excelRTDServer.py
> > ==============
> >
> > L281 ff:
> >
> > class TimeServer(ExcelRTDServer):
> > ..
> > def __init__(self):
> > ..
> > self.ticker = threading.Timer(self.INTERVAL, self.Update)
>
> Does that actually create a new thread? If so, every new thread has to
> call CoInitialize before it does any COM actions.
Yes, this creates a new thread. I've replaced that with
class MyTimer(threading.Thread):
def __init__(self, callback):
threading.Thread.__init__(self)
self.callback = callback
def run(self):
pythoncom.CoInitialize()
win32trace.write("started and CoInitialize'ed MyTimer-thread " +
str(threading.current_thread().ident))
while True:
time.sleep(2)
win32trace.write("MyTimer - callback")
self.callback()
Unfortunately, the error remains;(
===
How can I call on the interface not via IDispatch, but using vtable-based
direct call?
This gets called from Excel .. "CallbackObject" is provided by Excel and
implements IRTDUpdateEvent
def ServerStart(self, CallbackObject):
..
# Need to "cast" the raw PyIDispatch object to the IRTDUpdateEvent interface
IRTDUpdateEventKlass =
win32com.client.CLSIDToClass.GetClass('{A43788C1-D91B-11D3-8F39-00C04F3651B8}')
self.__callback = IRTDUpdateEventKlass(CallbackObject)
Here are the object types resulting from this code:
ServerStart - CallbackObject = <PyIDispatch at 0x095EF1C8 with obj at
0x061FADC4>
ServerStart - IRTDUpdateEventKlass =
win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x6.IRTDUpdateEvent
ServerStart - self.__callback = <win32com.gen_py.Microsoft Excel 12.0 Object
Library.IRTDUpdateEvent instance at 0x154547504>
==
What I want to try is cast the CallbackObject to IRTDUpdateEvent using some
QueryInterface construct, and then later call methods
on that interface ... but NOT via IDispatch.
The
self.__callback = <win32com.gen_py.Microsoft Excel 12.0 Object
Library.IRTDUpdateEvent instance at 0x154547504>
however is a
class IRTDUpdateEvent(DispatchBaseClass):
CLSID = IID('{A43788C1-D91B-11D3-8F39-00C04F3651B8}')
coclass_clsid = None
def UpdateNotify(self):
return self._oleobj_.InvokeTypes(10, LCID, 1, (24, 0), (),)
and calls UpdateNotify via IDispatch.
So: how can I cast/call without IDispatch?
Many thanks,
Tobias
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32