Dynamic Linking

Instead of grouping functions into libraries, later versions of Windows grouped these functions into a special type of executable called a DLL.

When you link a DLL, you specify which function you want to include in your application, and instead of copying in the entire contents of the DLL, the linker/compiler records the name of each externally referenced function along with the name of the DLL in which it resides.

When your application runs, Windows loads the required library so that all its functions are exposed, and it is then that the address of each function is resolved and dynamically linked to the application. That's why it's called dynamic linking. Figure 13-2 shows how dynamic linking works.

Figure 13-2

Only one copy of the library need be stored on disk. All the applications that need to use its functions access the same physical copy.

Dynamic linked libraries typically have the same file extension (*.dll), but this is not an absolute requirement. Custom controls, like those created in Visual Basic and C++, can have file extensions like *.ocx. Device drivers and some Windows system libraries sometimes use file extensions such as *.drv and *.exe.

0 0

Post a comment