What is a DLL?   

A Dynamic Link Library (DLL) is a Windows executable library module containing one or more Subs or Functions that can be called by executables or other DLLs.  Unlike executables, DLLs do not have a single entry point.  Instead, like libraries, DLLs have multiple entry points, one for each exported Sub or Function.

To get a better idea of how a DLL works, it helps to understand the difference between static and dynamic linking.  Static linking is the process of writing one or more modules, and then linking them, along with whatever other run-time, third-party, etc., libraries that may be needed to create a complete, stand-alone executable program.  When a program uses a Sub or Function from a static-link library, a copy of that Sub or Functions code is statically linked into the programs executable file.

If two programs that are running concurrently use the same routine from a library, they would each have their own copy of that routine.  It would be more efficient if the two programs could share a single copy of the routine.  DLLs provide that capability by resolving your application's references to external procedures at run-time.

In contrast to a static-link library, the code in a DLL is not linked into a program that uses the DLL.  Instead, a DLLs code and resources are in a separate executable file, usually with a .DLL extension.  This file must be present when the application runs.  You will still have to write one or more modules to implement the functions that are specific to your application.

However, the linking process is divided into two stages.  You first place DECLARE statements into your application to temporarily satisfy the references your program makes to the DLL services, in order to create an EXE (or DLL) file.  The second stage happens at run-time, when your program calls one of the DLLs services.

At that time, the Function calls in the program are dynamically linked to their entry points in the DLL(s).  The operating system resolves external references by establishing a link between the application calls and the code, in the DLL, that implement the required functions.  The Windows environment supports both static and dynamic linking.

 

See Also

Why use Dlls?

Creating a Dynamic Link Library

Private and Exported Procedures

Dll example

LibMain