0

When I try to load a .dll then the application first try to load the .dll from their local folder, if it is not there they try to load it using the %PATH% environment variable.

I don't mind if the OS is doing any other searches, but I am interested in the order of the search in the %PATH% environment variable.

Now, let's assume I have two versions of theis dll, and both pathes of those dlls are in the %PATH% environment variable.

Am I guaranteed that the first path that is containing the .dll in the %PATH% environment variable, is the path which the .dll will be loaded from?

10x.

sara
  • 3,824
  • 9
  • 43
  • 71
  • Yes... and no... it'll search the path in order, but depending on the OS, it may also search other paths, such as the folder the exe is in, windows directory etc first, whether or not they are in your path. You may want to have a look at: http://stackoverflow.com/q/2463243/592182. – forsvarir May 30 '12 at 14:07

1 Answers1

0

There is exact order in which DLL is searched.

Checkout this:

http://msdn.microsoft.com/en-us/library/7d83bc18%28v=vs.80%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx

UPDATE:

Windows will search in order as they appears in PATH variable.Please note, that full PATH variable consist from 2 parts:

System : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATH

Then is appended current user's PATH : HKEY_CURRENT_USER\Environment\PATH

rkosegi
  • 14,165
  • 5
  • 50
  • 83
  • They only say: 5.The directories listed in the PATH environment variable, but what does the order of those directories? – sara May 31 '12 at 08:50