Is the 'Implemented Categories' key needed when registering a Managed COM Component?

浪子不回头ぞ 提交于 2019-11-27 21:44:58

问题


When registering a managed class for COM Interop by hand, certain registry keys are needed. For example

HKEY_CLASSES_ROOT
  CLSID\[My Cls Id]
    InprocServer32
     (Default) = "mscoree.dll"
     Assembly = [My assembly name]
     etc.

I've noticed that when VS registers a library for COM Interop, it also adds a key

HKEY_CLASSES_ROOT
  CLSID\[My Cls Id]
    Implemented Categories
      {62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}

What is this key for, and is it absolutely necessary? As far as I can tell, life goes on just fine without it, but maybe I'm not encountering the circumstances where it is needed.


回答1:


It is a CATID, a component category. A control host can use it to, say, filter items that appears in a toolbox, only offering ones that implement an expected set of interfaces.

You can see a list of known component categories in the HKCR\Component Categories registry key. The one that Regasm.exe uses means "this COM server is implemented in .NET". Which is kinda useful to know since a .NET program should not use a COM server that is implemented in a managed language, it should use the metadata in the assembly directly.

CATIDs are not well documented. Which makes them fairly useless, you'll rarely have trouble if you simply omit them. If some control host vendor requires you to use a CATID to make your COM server usable in their host, they'll let you know about that explicitly.



来源:https://stackoverflow.com/questions/2070999/is-the-implemented-categories-key-needed-when-registering-a-managed-com-compon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!