[python-win32] com servers and py2exe

Mark Hammond mhammond at skippinet.com.au
Mon Jun 26 04:07:25 CEST 2006


> Py2exe supports making com servers as dlls or as exes.  After I
> create a com server with py2exe, how do I get it registered?

If it is a .exe, you just run it.  If it is a DLL, you use regsvr32.exe to
register it - ie, you register them just like any other COM EXE or DLL
files.

> If I need to register additional registry keys when the
> com server is registered, how is that handled?

py2exe and pywin32 have special support for "DllRegisterServer" and
"DLLUnregisterServer" functions - just create functions of this name in your
main module, and py2exe will find and use them (see boot_com_servers.py in
the py2exe distro).  Your "normal" .py implemented COM objects can leverage
the same thing by using something like:

def DllRegisterServer():
  ...
def DllUnregisterServer():
  ...
if __name__=='__main__':
  win32com.server.register.HandleCommandLine(...,
                                             finalize_register=DllRegisterSe
rver,
                                             finalize_unregister=DllUnregist
erServer)

Mark



More information about the Python-win32 mailing list