[python-win32] COM server AddIn
Johannes Brunen
jbrunen at datasolid.de
Thu Jul 7 13:22:57 CEST 2005
Hi Mark,
now I have made some progress! Using the win32traceutil worked well.
However the real essential part was the addition of the _typelib_guid_
variable
to the server class. Below, I have added the working example. Could you
confirm that this is the proper way of using the modules?
Two questions remains:
1.) The following code line seems to be unnecessary. The AddIn sever works
without it as well. What is
the idea for this line? Do I need it?
universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1,
2, ['ICADdyAddIn'])
2.) Debugging the server gives me now the following lines in the trace debug
window, which I don't understand. Can you explain what their
meaning is?
Object with win32trace dispatcher created (object=None)
in <Addin1.AddIn1 instance at 0x1F8B9DC8>._QueryInterface_ with unsupported
IID IMarshal ({00000003-0000-0000-C000-000000000046})
in <Addin1.AddIn1 instance at 0x1F8B9DC8>._QueryInterface_ with unsupported
IID IMarshal ({00000003-0000-0000-C000-000000000046})
in <Addin1.AddIn1 instance at 0x1F8B9DC8>._QueryInterface_ with unsupported
IID {0000001B-0000-0000-C000-000000000046}
({0000001B-0000-0000-C000-000000000046})
in <Addin1.AddIn1 instance at 0x1F8B9DC8>._QueryInterface_ with unsupported
IID IStdMarshalInfo ({00000018-0000-0000-C000-000000000046})
in <Addin1.AddIn1 instance at 0x1F8B9DC8>._QueryInterface_ with unsupported
IID IExternalConnection ({00000019-0000-0000-C000-000000000046})
in <Addin1.AddIn1 instance at 0x1F8B9DC8>._QueryInterface_ with unsupported
IID {4C1E39E1-E3E3-4296-AA86-EC938D896E92}
({4C1E39E1-E3E3-4296-AA86-EC938D896E92})
Thank you very much for your supporting help and time!!
Best wishes
Johannes
##
## Addin1.py - A very simple CADdy++ AddIn server
##
from win32com import universal
from win32com.server.exception import COMException
from win32com.client import gencache
import pythoncom
import sys
#
# Support for COM objects we use.
#
gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2,
bForDemand=True) # CADdy.tlb
#
# The TLB defining the interfaces we implement
#
#universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0,
1, 2, ['ICADdyAddIn'])
class AddIn1:
_com_interfaces_ = ['ICADdyAddIn']
_public_methods_ = []
_reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER
_reg_clsid_ = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}"
_reg_progid_ = "CADdyAddIn.PythonTest1"
_reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy"
_typelib_guid_ = '{9C3BB401-114D-11D4-AC72-00105A4925FC}'
def __init__(self):
self.appHostApp = None
self.CLSID = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}"
self.ProgId = "CADdyAddIn.PythonTest1"
self.Description = "CADdyAddIn.PythonTest1"
def Exit(self):
"""method Exit"""
self.appHostApp = None
def Init(self, theCADdy):
"""method Init"""
self.appHostApp = theCADdy
pUIManager = theCADdy.UIManager
pUIManager.Information("Init Python Test AddIn1...")
def RegisterAddin(klass):
pass
def UnregisterAddin(klass):
pass
if __name__ == '__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(AddIn1)
if "--unregister" in sys.argv:
UnregisterAddin(AddIn1)
else:
RegisterAddin(AddIn1)
More information about the Python-win32
mailing list