Creating COM server Events?

Dan danbrwn at
Wed Mar 29 22:07:03 CEST 2006

Here is what little I have so far. I can use clients to call the advise
method and store in the mylist set (should be named myset i guess).
Now, I want the client to have to implement a callback and register the
interface in the AdviseChange method.

mylist= set()
class TestTTechPycom:
    _public_methods_= ["AdviseChange","ShowTheList"]
    _reg_progid_ = "TestTTechPycom"
    _reg_clsid_ = "{D5BA19AA-0F4D-4022-A811-40C087FE089A}"

    def AdviseChange(self):
        if not self in mylist:
            print "added"
            print "already added"

    def ShowTheList(self):
        print mylist

if __name__=='__main__':
    print "Registering TestTTechPycom server"
    import win32com.server.register

So, when I call the AdviseChange now, a unique ID is placed into
mylist. If you run ShowTheList()
it will give a different instance ID for each registered client. Great!
So given something like;

def AdviseChange(self,interfacepointer)
How do I define what the interface for the interfacepointer should look
like. I mean in my typelib listed in my previous post, the interface
for the events were marked as Source so that COM knows that the client
must implement them. How do you do that in Python? Dan

More information about the Python-list mailing list