The principle of 1.Windows dynamic link library
Dynamic link library (DLLs) is developed from the concept of C language function library and Pascal Library unit. All C language standard library functions are stored in a library of functions, and users can also use Lib program to create their own library of functions. In the process of linking the application, the linker copies the function code called by the program from the library file and adds the function code to the executable file. This
Method of storing functions only in the compiled. The obj file is more useful for code reuse than it is in.
But with the advent of a multitasking environment such as windows, the method of functional libraries is cumbersome. If every program has its own function to complete screen output, message processing, memory management, dialog boxes, and so on, then Windows programs will become very large. The development of Windows requires allowing several simultaneous programs to share a single copy of a set of functions. Dynamic
This is where the link library occurs. Dynamic link libraries do not need to be compiled or linked, and once loaded into memory, the DLLs function can be used by any running application software in the system without having to load another copy of the DLLs function into memory.
1.1 Working principle of dynamic Link library
The words "dynamic link" indicate how DLLs works. For a regular library, the linker copies all the library functions it needs and passes the exact function address to the program that calls the functions. For DLLs, functions are stored in a separate dynamic-link library file. When you create a Windows program, the link process does not link the DLLs file to the program. Until Cheng
Order to run and call a function in a DLLs, the program only requires the address of this function. At this point, Windows looks for the called function in the DLLs and sends its address to the calling program. In this way, DLLs reaches the limit of the reusable code.
Another convenience of a dynamic-link library is that modifying a function in a dynamic-link library can automatically propagate to all programs that invoke it without having to make any changes or processes to the program.
DLLs not only provides the mechanism of function reuse, but also provides the mechanism of data sharing. Any application can share a block of memory resources managed by the DLLs that is loaded into memory. DLLs, which contains only shared data, is called a resource file. such as the font files for Windows.