13.2. Introducing DLLs

We mentioned before that function libraries can be linked or incorporated into applications when required. There are two types of linking: static and dynamic. Static linking occurs at design time, when you create the application. Dynamic linking occurs at runtime.

13.2.1. Static Linking

Most programming languages provide the capability to access some operating system functions. They usually also allow you to create and store your own custom functions which you can compile into library (*.lib) files, and then merge into your applications.

When an executable program is compiled, a Linker scans the application for references to external functions and libraries, and then copies them into the final executable, thereby linking them to your application. This is called static linking, because the addresses your program uses to access these functions are fixed into the executable and remain unchanged (static) when the program runs. Figure 13-1 shows how static linking works.

Figure 13.1. Figure 13-1

Although newer compilers allow you to copy individual functions, older ones typically copied the entire module to the application when linking each library. This meant that all the library's functions were merged into the executable, regardless of whether they were needed or not.

Of course, copying the entire module to the application increased the resulting file size. ...

Get Access 2003 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.