Does anyone know if there is a way to get py2exe to generate a COM server
that automatically registers the server's type library at the same time
the
server registers?
In the script version of my Python COM server I added the following code
to my 'main':
path = os.path.abspath("test_script_server.tlb")
if '--register' in sys.argv[1:]:
tlb = pythoncom.LoadTypeLib(path)
pythoncom.RegisterTypeLib(tlb, path, None) # Helpdir = None, LCID
# is not required despite
# what ActiveState might
say
print "Type library registered."
elif '--unregister' in sys.argv[1:]:
tlb = pythoncom.LoadTypeLib(path)
tlbattr = tlb.GetLibAttr()
iid = tlbattr[0] # pyIID stored in first element of tuple
try:
# All our type libraries are version 1.0, LCID =1
pythoncom.UnRegisterTypeLib(iid, 1, 0, 1, pythoncom.SYS_WIN32)
print "Type library unregistered."
except:
print "Failed to unregister type library."
This works fine for the uncompiled COM server, but when it
gets built into an .exe or .dll this code is never executed.
From what I can tell, py2exe has its own boot code that handles
the --register and --unregister stuff.
Is there some way to insert your own bootstrap perhaps?
Any help would be greatly appreciated.
Thanks,
Phil
|