Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In Windows, what is the preference of how Windows looks through these folders to find .dlls? For example, if I have two versions of the same dll, one in the System 32 folder and one on the System Path, where does Windows look first?

share|improve this question

4 Answers 4

Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll.

Windows then searches for the DLLs in the following sequence:

The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

The directory where the executable module for the current process is located.

The current directory.

The directories listed in the PATH environment variable.

Note that under 64 bit windows 32 bit processes use the 32 bit system32 directory- not the 64 bit one.

It's slightly different pre sp1 of 2k3 or XP.

share|improve this answer

Depends on your PATH environment variable, but usually %windir%\System32 is added before %windir%.

Wearing my developer hat: wherever possible I'd avoid installing anything to either of these folders, especially for recent OS versions with side-by-side assembly support (e.g. XP/Vista/2008).

If you've installed an application that's put a .DLL in both places then I'd contact the developer to fix it.

share|improve this answer
    
And @chickeninabiscuit is right too :-) –  devstuff Jul 10 '09 at 0:40

Have a bang on this:

http://msdn.microsoft.com/en-us/library/7d83bc18(VS.80).aspx

Note the "Order has changed!" comment that references this page:

http://msdn.microsoft.com/en-us/library/ms972822.aspx

share|improve this answer

DLL loading is handled by the Windows API LoadLibrary function and the search order is described in the documentation for that: http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.