The search path that Windows uses to locate the DLL

Source: Internet
Author: User
Tags file system

The sequence of Windows search DLL files is: (1) memory (2) KnownDLLs (3) List and. Local (4) application directory (5) Current working directory (6) system directory (7) PATH variable

Always feel not quite understand, so check the data to confirm.

Check MSDN as follows: http://msdn.microsoft.com/zh-cn/library/7d83bc18.aspx

With implicit and explicit linking, Windows first searches for "known DLLs," such as Kernel32.dll and User32.dll. Windows then searches for DLLs in the following order:

The directory where the executable module for the current process resides.

The current directory.

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

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

The directory listed in the PATH environment variable.

Implicit linking is sometimes referred to as static load or load-time dynamic linking. Explicit linking is sometimes referred to as dynamic load or run-time dynamic linking.

Under an implicit link, the executable file that uses the DLL is linked to the import library (. lib file) provided by the creator of the DLL. The operating system loads the DLL when it is loaded using the DLL's executable file. The client executable invokes the DLL's exported functions as if they were contained within an executable file.

Under explicit linking, an executable file that uses a DLL must make a function call to explicitly load and unload the DLL and access the DLL's exported functions. The client executable file must call the exported function through the function pointer.

The "known DLL" (informal name) feature refers to a list of DLLs (dynamic-link libraries) that are specially handled by the kernel's module loader. When the loader discovers a program that has dynamic linking to a known DLL, it uses the known copy immediately, ignoring the search algorithm that is normally applied to the module's load.

What is the reason for the memory written above? Search for dynamic libraries is first memory, if there is no need to load in memory, otherwise need to search and then loaded into memory. The main advantage of DLLs is that they save memory and reduce switching operations. Many processes can use a single DLL to share a copy of the DLL in memory. Instead, for each application built with a static link library, Windows must load a copy of the library code in memory.

The feeling. The local file is like a configuration or something, and no information is found.

Currently working directory (current Working directory), in general, each process has a directory associated with it (hierarchical file system), called the current working directory of the process. If the program has just entered the main entrance, the current working directory is actually the directory to start the program, but the current working directory can be set through the program or with OpenFileDialog, SaveFileDialog and other objects identified by the directory changes.

The directory where the application is located, the directory from which the process starts, that is, the directory where the program file itself resides. is different from the current working directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.