title: What's the appropriate place to call CoInitialize/CoUninitialize across DLL's?
body: <p>I'm implementing a DLL containing <a href="https://stackoverflow.com/questions/9434762/pass-adoconnection-from-vba-to-delphi">a shared ADO Connection</a> by using the <code>ConnectionObject</code> property of <code>TADOConnection</code> and passing it across DLL boundaries into other instances of <code>TADOConnection</code>. I need to make sure COM is initialized, so I need to call <code>CoInitialize</code> / <code>CoUninitialize</code>. Currently it's in the context of a VCL main thread, but could be elsewhere in another thread, which of course <a href="https://stackoverflow.com/questions/9286600/when-do-i-need-to-call-coinitialize-in-this-scenario?rq=1">requires its own instance of COM</a>. I'm not currently implementing multi-threading.</p>
  
  <p>Where is the appropriate place to call these; inside the DLL (during loading/unloading), outside the DLL (calling process), or both? Considering it's only one thread, shouldn't it be only one time outside the DLL in the original process?</p>
  
  <p>I'm assuming the original calling thread should be solely responsible for this, since COM runs in the context of a thread. Of course calling them on both sides shouldn't hurt any, however it would also create multiple COM instances.</p>
  
  <p>Long story short... Is it "safe to be safe" in this case? Or is it important to only keep one COM instance?</p>