COM object registration

dsavitsk dsavitsk at
Mon Sep 16 20:17:42 CEST 2002

if the module below is run from the command line, it registers and works
fine.  if, however, it is imported and the register() method is executed it
does not work (giving a 'localserver' error). (the registration process
works, but it can't then be used via Dispatch) seemingly the name of the
class (here testServer) can't be found.

even though it doesn't work locally, however, it will still work as a DCOM
server, that is, if it is registered from the command line on another
computer it works.

is this expected behavior? is it a mangled name of some sort? is there a
better way to register a COM obect via code.

# -------   sample code   -------

import pythoncom

class testServer:

    _reg_clsid_ = '{C627B7F9-E078-4872-B06D-7DB33C3BC7A4}'
    _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
    _reg_progid_ = 'test.Server'
    _public_methods_ = ['GET_VALUE']

    def GET_VALUE(self): return 0

def register():
    import win32com.server.register

if __name__ == '__main__': __register()

# ------- end sample code -------

More information about the Python-list mailing list