title: Calling LoadLibrary from DllMain
body: <p><a href="http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx" rel="nofollow noreferrer">MSDN says:</a></p>
  
  <blockquote>
    <p>It must not call the LoadLibrary or LoadLibraryEx function
    (or a function that calls these functions),
    because this may create dependency loops in the DLL load order.
    This can result in a DLL being used before the system has executed its initialization code.</p>
  </blockquote>
  
  <p>I tried to call <code>LoadLibrary</code> from DllMain and nothing happened.  </p>
  
  <p>The only issue that I see is that loaded DLL will use functions in my DLL before rest of my DllMain executes.</p>
  
  <p><strike>Why I must not call LoadLibrary in DllMain?</strike></p>
  
  <h2>EDIT:</h2>
  
  <p>OK, I realized that I must not call LoadLibrary in DllMain just because I must <em>believe</em> MSDN as other believers do (I saw some wrong things there, but I should forget them too).<br>
  And because something may happen in newer versions of Windows (although there nothing was changed for last ten years).</p>
  
  <p>But can anyone show a code which will reproduce something bad what happens when <code>LoadLibrary</code> is called in DllMain? In any existing Windows OS?<br>
  Not just a call of one singleton initialization function inside another, but <code>LoadLibrary</code> in DllMain?</p>