Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
393 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 HKCRComponent 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...