Larry Osterman's WebLog

Confessions of an Old Fogey
Blog - Title

When do you need an APPID in your COM registration?

When do you need an APPID in your COM registration?

  • Comments 3

I recently received this question from a reader:

When Does ATL component need to register a AppId for it to work( Our component is an IE plug-on)? There is a macro:DECLARE_REGISTRY_APPID_RESOURCEID. It will triger three registry entries for AppId by the default DllRegisterServer implementation from ATLDllModuleT(seems to me). Do we need all of them? I am try to remove all possible unused registry entries from setup file.

It's actually a good question, because the documentation of all the rules associated with COM activation are not incredibly well documented.  Most people simply copy template examples from another working COM object and use those.  Every once in a while, when I'm bored, I scan through the registry on my machines looking at the various COM registrations - you can often tell which groups own which components simply by looking at the common items (especially misspellings and the like) in their COM registry.

We've actually had a team of people in-house analyzing the COM registrations of the various COM objects in the system to ensure that there's no redundant or invalid information in them, it's been an eye opener (I was able to remove about 80% of the registry entries for the audio stack after chatting with the guy reporting these issues).

So when DO you need an appid?  Well, for many cases, you don't, but ATL doesn't know that so by default it assumes that you will need one.

You need to specify an appid if one of the following is true:

  1. Your COM object is hosted in a service
  2. Your COM object has custom launch permissions
  3. Your COM object has custom access permissions
  4. You want to specify a default bitness for the COM server when launching an out-of-proc COM object. 
  5. Your COM object runs as another user
  6. Your COM object needs to run on another system (unless you specify a COSERVERINFO in your call to CoCreateInstanceEx)
  7. Your COM object needs to set the default authentication level (used if you don't call CoInitializeSecurity directly)
  8. Your COM object needs to specify the RPC endpoints for communication (or the TCP port number, etc)
  9. Your COM object should run on the same machine as the storage (ActivateAtStorage)
  10. Your COM object runs using the DLL surrogate
  11. Your COM object needs to set its software restriction trust level

If those are true, you need an appid, otherwise it's unnecessary (and takes up space on the disk).

Essentially, if you ever need to specify one of the appid keys, you need to specify an appid.  If you don't need to specify those keys, then you don't need an appid.  From what I've seen, the vast majority of COM objects don't.

 

The DECLARE_REGISTRY_APPID_RESOURCEID macro allows you to specify an RGS file that will be used to register the APPID for your COM object if you need one, but if you don't want ATL to register one, you can simply remove the macro.

Page 1 of 1 (3 items)