Dynamic linking has the following advantages over static linking:
Processes that load a DLL at the same base address can use a single DLL
simultaneously, sharing a single copy of the DLL code in physical memory.
Doing this saves memory and reduces swapping.
When the functions in a DLL change, the applications that use them do not
need to be recompiled or relinked as long as the function arguments, calling
conventions, and return values do not change. In contrast, statically linked
object code requires that the application be relinked when the functions
change.
A DLL can provide after-market support. For example, a display driver DLL
can be modified to support a display that was not available when the
application was initially shipped.
Programs written in different programming languages can call the same DLL
function as long as the programs follow the same calling convention that the
function uses. The calling convention (such as C, Pascal, or standard call)
controls the order in whichthe calling function must push the arguments onto
the stack, whether the function or the calling function is responsible for
cleaning up the stack, and whether any arguments are passed in registers.
For more information, see the documentation included with your compiler.
A potential disadvantage to using DLLs is that the application is not
self-contained; it depends on the existence of a separate DLL module.
The system terminates processes using load-time dynamic linking if they
require a DLL that is not found at processstartup and gives an error message
to the user. The system does not terminate a process using run-time dynamic
linking in this situation, but functions exported by the DLL are not available
to the program.
DLLs can define two kinds of functions:
exported and internal. The exported functions can be called by other modules.
Internal functions can only be called from within the DLL where they are
defined. Although DLLs can export data, its data is usually only used by
its functions.
DLLs provide a way to modularize applications so that functionality can be
updated and reused more easilly. They also help reduce memory overhead when
several applications use the same functionality at the same time, because
although each application gets its own copy of the data, they can share the
code.
TMT Pascal Multi-target support DLLs for Win32
and OS/2 compilation targets. DLLs are not supported for MS-DOS protected
mode target.