[python-win32] pythoncom multithread troubles
mhammond at skippinet.com.au
Tue Nov 28 02:52:20 CET 2006
> What I have tried:
> - Use DispatchEx instead of Dispatch: this works with other COM
> servers, like MS Word and Excel, but not with mine. Probalby has to do
> with the fact that they are local servers, whereas mine is inproc.
> - CoInitialize, CoInitializeEx with flags: no luck
> - using CoGetClassObject instead of CoCreateInstance in pythoncom,
> since I read that this would be the way to go if you require multiple
> instances of a server: I didnt manage to get it working because the
> return type is different to that of CoCreateInstance and I dont know
> how to deal with this (ctypes)
> - CoCreateInstanceEx: no luck
> In short I am looking for a way to always get a new instance of the
> COM server when using dispatch, even if it is inproc. I am open to any
> suggestions and corrections to my limited COM knowledge
Try looking at the source to win32com.client.Dispatch, and see how it first
tries GetActiveObject() - try just calling CoCreateInstance() without the
check for GetActiveObject.
If that doesn't work, I'm afraid you are probably SOL - it would be the
object itself implementing these semantics and therefore hard to defeat.
More information about the Python-win32