Obtaining two references to a COM server
Mark Hammond
mhammond at skippinet.com.au
Tue May 14 20:30:22 EDT 2002
Lars von Wedel wrote:
> Hi,
>
> we are using Python as a COM client of an application
> and we want to start two server instances. This works
> fine in VB using
>
> Dim anw As Object 'Das Anwendungsobjekt
> Set anw = CreateObject("Parsival.Application.1")
> anw.Visible = true
>
> Dim anw2 As Object 'Das Anwendungsobjekt
> Set anw2 = CreateObject("Parsival.Application.1")
> anw2.Visible = true
>
> However, using Python Win32 extensions,
>
> Dispatch("Parsival.Application.1")
>
> will receive two references which point to the same
> object.
>
> Any ideas on this different behavior? How can we achieve
> the VB behavior in Python?
Try using:
ob = pythoncom.CoCreateInstance("prog.id", None,\
pythoncom.CLSCTX_SERVER,
pythoncom.IID_IDispatch)
ob = Dispatch(ob)
and it should do what you expect.
Mark.
More information about the Python-list
mailing list