title: When does a coclass have to be properly defined in an .idl?
body: <p>I've created several shell extension classes (e.g., a property handler, drag-and-drop handler, context-menu handler, etc.), and when adding the necessary interfaces to the C++ classes themselves, I've never bothered changing the coclass definitions in the .idl file.  So the coclass definitions in the .idl file just have the ATL project defaults, i.e.:</p>
  <pre><code>coclass DragDropHandler
  {
      [default] interface IDragDropHandler;
  };
  </code></pre>
  <p>Nonetheless, as long as the actual interfaces and COM map are implemented properly in the C++ class, Explorer is able to load and call my shell extension classes just fine.</p>
  <p>But just recently I created a class that implements a custom interface.  I didn't have the coclass entry in .idl file correct, and <code>CoCreateInstance</code> failed with <code>E_NOINTERFACE</code>.  Upon fixing the .idl file so that the coclass had the correct interface, it wound up working.</p>
  <p>So I was wondering why the .idl file might not have to be updated and correct for shell extension classes, whereas when instantiating a class on my own, it had to be right.  Does one approach involve using a type library, whereas the other doesn't?</p>