Connecting to running win32com

Mark Hammond MarkH at ActiveState.com
Tue Oct 17 19:04:50 EDT 2000


"ghubbar" <ghubbar at sandia.gov> wrote in message
news:39ECB9EF.D4EDEE5A at sandia.gov...
> Hi again,
>
> I lost track of the thread, so I am starting a new one.

I'm sorry, but you _will_ need to go back to that thread - there is
very important information there relating to your situation, and I'm
not going to attempt to repeat it.

A minor issue:

> class MyPythonComServer:
>         _public_methods_ = ["ReturnMessage"]
>         _reg_progid_ = "StatusData.Access"
>         _reg_clsid_ = "{38C739C1-4EC0-11D4-BDFB-005004D78D9D}"
>         print "Creating ComServer"

You are misleading yourself with that "print".  The ComServer is _not_
being created at that time.  All that is being created is the _class_.
The COM object is an _instance_ of a class.  Add an __init__ function,
and add the print there.

A much bigger problem is:

> if __name__ == '__main__':
>         print "Registering COM server..."
>         import win32com.server.register
> apply(win32com.server.register.RegisterClasses([MyPythonComServer],
> {"debug":1}))
>
>         app = MyApp(0)
>         app.MainLoop()

You can _not_ try and start your app at this point.  All you should be
doing here is registering your object.  You must setup your code such
that COM itself automatically boots up your application - ie, your
object constructor must take care of this.


However, you will need to re-read the other thread to understand that
a new COM object will be created _every_ time a client creates one.
If you want the illision of a single COM object for all clients, you
_must_ re-read that thread.

Mark.






More information about the Python-list mailing list