I have been working on this all day, with no joy. Some help would be appreciated :-)
I have a simple COM server (that I found on the internet): #------------------------------------------------------------------- import pythoncom import sys class HelloWorld: #pythoncom.frozen = 1 if hasattr(sys, 'importers'): _reg_class_spec_ = "__main__.HelloWorld" _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _reg_clsid_ = '{E3D5F332-F080-47B3-A319-A3A0E287E466}' _reg_desc_ = "Python Test COM Server" _reg_progid_ = "Python.TestServer" _public_methods_ = ['Hello'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] def __init__(self): self.softspace = 1 self.noCalls = 0 def Hello(self, who): self.noCalls = self.noCalls + 1 # insert "softspace" number of spaces print "Hello" + " " * self.softspace + str(who) return "Hello" + " " * self.softspace + str(who) if __name__=='__main__': import sys if hasattr(sys, 'importers'): # running as packed executable. if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]: # --register and --unregister work as usual import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld) else: # start the server. from win32com.server import localserver localserver.main() else: import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld) #------------------------------------------------------------------- This works just fine as a python module. I can run it, register the COM server and use the Hello method in VBA code inside Excel. However, I would like to make a DLL, register it, and be able to have the same access to the COM server. I have not been able to do that so far. I have the following simple setup.py module #------------------------------------------------------------------------ from distutils.core import setup import py2exe setup(com_server = ["test"]) #------------------------------------------------------------------------ Using this with py2exe generates both test.dll and test.exe. I can call test.exe with '--register' on the command line and the COM server is registered. However, when I use regsvr32 to register test.dll, the COM server does not work with Excel. (although regsvr32 says that the DLL has been successfully registered). What am I missing?
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32