title: Define a COM class that is only createable from the same EXE where it is registered
body: <ol>
  <li>If have an EXE with a STA in the main thread</li>
  <li>Inside the EXE a second thread with another STA is created.</li>
  <li>This second thread with the STA should publish a class factory with CoRegisterClassObject that is only available from this process.</li>
  </ol>
  <p>When I use CoRegisterClassObject with <code>CLSCTX_INPROC_SERVER</code> and REGCLS_MULTIPLEUSE the main thread creates the object with <code>CLSCTX_ALL</code> I get the error &quot;class not registered&quot;.</p>
  <p>When I use <code>CoRegisterClassObject</code> with <code>CLSCTX_LOCAL_SERVER</code> and <code>REGCLS_MULTIPLEUSE</code> the main thread can create the object. But the next instance of the program will create the object inside the first process.</p>
  <p>Using <code>CLSCTX_INPROC</code> flag inside <code>CoCreateInstance</code> will always say that the class is not registered.</p>
  <p>BTW: Because I register the class by my own always when the program is started there are no registry keys except the required one the the typelib.</p>
  <p>More detailed explanation why I need this:
  The created class uses pointers and function internally created in the context of the EXE. Just think that I am programming an &quot;Application&quot; object that should support only functions inside this process and files and objects managed by this session. And I need this COM object because it is used inside a VBScripting Host and is again exposed to other COM objects.</p>
  <p>Is there a way to registering a class factory that only support creation from inside my EXE?</p>