[python-win32] COM Dispatch w/multiple sessions?

Roger Upole rwupole at msn.com
Tue May 6 10:23:42 CEST 2008


Adam Pletcher wrote:
> I have a tool that interacts with a COM server created by a third-party 
> application.  My users sometimes need to open mutiple copies of that 
> application.  You can probably guess where this is going.
> Is there any way to tell win32com.client to connect to a specific 
> instance/process of that application?
> 
> I'm currently using the typical win32com.client.Dispatch, which seems to 
> just bind to the first process opened using that COM interface.  Any 
> suggestions/workarounds appreciated.
> 
> - Adam

Some applications support this behaviour by using a Moniker to
identify a particular instance.  For example, Excel uses a file
moniker (pythoncom.CreateFileMoniker), and the object's
Bind method will connect to an instance of Excel that has
that file loaded.
If your app supports moniker semantics, you might be able
to do it that way.

           Roger



More information about the python-win32 mailing list