Hi, Ive patched comtypes to support COM categories. In my case, an OPC client requires categories. It checks the registry for supported categories and if not one category is found, it will not support interaction with the server even if the server has implemented and published all required interfaces.
An object can publish its supported categories which are represented by an registry entry. Ive changed the "comtypes\server\register.py" and added a few lines (see diff below). I'm not sure if I used the registry functions correctly, but it works for me. Using the following code, you can add a new attribute "_reg_catids_" to your python COM class which should be a list of GUID strings: class MyComServer(CoClass): (...) _reg_catids_ = [ '{ FIRST CATID }', '{ SECOND CATID }', ] (..) This is probably not the most flexible way to do it (it may support e.g. interface objects instead of strings), but for me it works perfectly. It would be nice if this could be added to comtypes trunk. This is the diff: --- C:/Python26/Lib/site-packages/comtypes/server/register.py.old Mi Aug 19 22:17:08 2009 +++ C:/Python26/Lib/site-packages/comtypes/server/register.py Di Apr 17 10:17:47 2012 @@ -296,6 +296,12 @@ append(HKCR, "CLSID\\%s\\LocalServer32" % reg_clsid, "", "%s %s" % (exe, script)) else: append(HKCR, "CLSID\\%s\\LocalServer32" % reg_clsid, "", "%s" % exe) + + reg_catids = getattr(cls, "_reg_catids_", None) + if reg_catids is not None: + append(HKCR, "CLSID\\%s\\Implemented Categories" % reg_clsid, "", "") + for cat_id in reg_catids: + append(HKCR, "CLSID\\%s\\Implemented Categories\\%s" % (reg_clsid, cat_id), "", "") # Register InprocServer32 only when run from script or from # py2exe dll server, not from py2exe exe server. ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users