title: Trying to load a DLL with LoadLibrary and get R6034 "An application has made an attempt to load the C runtime library incorrectly"
body: <p>I'm writing a wrapper program that loads Winamp input plugins.  I've got it working well so far with quite a few plugins, but for some others, I get an error message at runtime when I attempt to call LoadLibrary on the plugin's DLL.  (It seems to happen mostly with plugins that were included with Winamp.)  A dialog appears and gives me the error code and message above.  This happens, for example, with the in_flac.dll and in_mp3.dll plugins (which come with Winamp).  Any ideas on how I can remedy this situation?</p>
  
  <p>EDIT:
  This basically iterates through the plugins in a directory and attempts to load and then free each one.  Some plugins produce the error I mentioned above, while others do not.</p>
  
  <pre><code>wstring path = GetSearchPath();
  
  FileEnumerator e(path + L"in_*.dll");
  
  while(e.MoveNext()) {
  
      wstring pluginPath = path + e.GetCurrent().cFileName;
  
      MessageBoxW(NULL, pluginPath.c_str(), L"Message", MB_OK);
      HINSTANCE dll = LoadLibraryW(pluginPath.c_str());
      if(!dll) {
  
          pluginPath = wstring(L"There was an error loading \"") + wstring(e.GetCurrent().cFileName) + L"\":\n" + LastErrorToString();
          MessageBoxW(NULL, pluginPath.c_str(), L"Error", MB_OK);
  
          continue;
  
      }
  
      FreeLibrary(dll);
  
  }
  </code></pre>