The Nature of DLLsThe term dynamic link has special implications for programmers. When a routine is said to be linked dynamically to a program, it means that the routine, whether a subroutine or function, is not connected to the program until after the program is compiled. The function is available at runtime only. The functions that you write in the code window are statically linked, meaning that the functions combine with the rest of your source code when you compile the program. The DLL files, however, do not merge with your program. Your program has runtime access to these routines, but your program's EXE file does not contain the physical DLL routines at any time. This difference is critical when it comes to using functions found in such places as dynamic link libraries, because neither the library nor the functions that your application calls are ever considered to be part of your program. The API functions never add to the size of your application's files. During program execution, these routines are loaded just long enough to run; then, if they are no longer needed, the Windows operating system can free up their resources so that more memory and CPU time is left for new routines that might start up. The big advantage to such dynamic linking is not, however, its efficient use of resources. If Windows changes, the DLLs are replaced with new DLLs. Therefore, your applications will be able to support new Windows features without you needing to recompile every application that uses a Windows API. For example, you may recall that Windows 95 changed the look of windows. The icons in the upper-right corner of a window are different than the Windows 3.11 icons. Every Visual Basic program that calls a Windows API to display a window works in either Windows environment. Such a program, when run in a Windows 3.11 environment, would show the old icons. The same program, when run in a Windows 95 environment, shows the new icons, even though the program itself did not change. Therefore, in most cases, your programs that access the Windows API require no change when you move between Windows versions.
|
|
![]() |
![]() |
|||