title: Search path for a DLL referenced by a plug-in DLL
body: <p>I'm writing a Windows application plug-in (as a DLL) in native C++. Let's call it <code>myplugin.dll</code>. My plug-in references another DLL which we'll call <code>other.dll</code>.</p>
  
  <p>My plug-in is installed in the <code>myplugin</code> subdirectory of the application's <code>plugins</code> directory:</p>
  
  <pre><code>application.exe
  plugins\
      myplugin\
          myplugin.dll
  </code></pre>
  
  <p><code>myplugin.dll</code> links implicitly to <code>other.dll</code>. I cannot delay-load <code>other.dll</code> because it exposes classes with virtual methods, and virtual method tables being considered as data, they cannot be imported from delay-loaded DLLs.</p>
  
  <p>I would naturally like to place <code>other.dll</code> in the <code>plugins\myplugin</code> directory, next to <code>myplugin.dll</code>, but by default Windows will not look in <code>plugins\myplugin</code> when searching for <code>other.dll</code> (<a href="https://msdn.microsoft.com/en-us/library/7d83bc18.aspx" rel="nofollow noreferrer">source</a>).</p>
  
  <p>What are my options here, other than placing <code>other.dll</code> in the root directory of the application?</p>
  
  <p>(While the question <a href="https://stackoverflow.com/questions/3832290/altering-dll-search-path-for-static-linked-dll">Altering DLL search path for static linked DLL</a> is related, it describes a scenario that doesn't quite make sense: an application implicitly linking against a plug-in DLL. I believe that a clear, typical scenario may help uncover additional solutions to this common issue, such as explicitly loading <code>other.dll</code> when <code>myplugin.dll</code> gets loaded by the application, if that would be possible.)</p>
  
  <p>Edit: another similar question: <a href="https://stackoverflow.com/questions/2206270/plugin-dlls-that-depend-on-other-dlls">Plugin DLLs that depend on other DLLs</a></p>
  
  <p>Edit: I found a solution to the problem, see the accepted answer below. As far as I know, this is the cleanest solution. I hope it helps someone else.</p>