What Is a Dynamic Link Library?

Dynamic Link Library (Dynamic Link Library or Dynamic-link Library, abbreviated as DLL) is a way for Microsoft Corporation to implement the concept of shared function library in Microsoft Windows operating system. These library functions have the extension ".dll", ".ocx" (containing ActiveX-controlled libraries) or ".drv" (legacy system driver).

The original purpose of the DLL was to save disk and memory space required by the application. In a traditional non-shared library, a portion of the code is simply attached to the calling program. If two programs call the same subroutine, two copies of that code will appear. Instead, the code shared by many applications can be split into a DLL, stored as a file on the hard disk, and an instance used in memory. The widespread use of DLLs allowed early windows to run under tight memory conditions.
DLLs provide the common benefits of shared libraries such as modularity. Modularity allows only code and data in a DLL shared by several applications to be changed without changing the application itself. This modular basic form allows applications as large as Microsoft Office, Microsoft Visual Studio, and even Microsoft Windows itself to use more compact patches and service packs.
Another benefit of modularity is the use of the plugin's common interface. The single interface allows the old modules to be integrated seamlessly with the previous application runtime as the new modules, without requiring any changes to the application itself. This idea of dynamic expansion has reached its extreme in ActiveX.
Despite so many advantages, there is a disadvantage to using DLLs: DLL hell, that is, several applications are using the same shared DLL library to have a version conflict. Such conflicts can be resolved by putting different versions of the problem DLL in the folder where the application is located instead of in the system folder; however, this will offset the space saved by the shared DLL. At present, Microsoft .NET regards solving DLL hell as its goal, which allows different versions of the same shared library to coexist side by side. Since modern computers have enough disk space and memory, this can also be used as a reasonable implementation method [1]
Memory management
in
  1. Extended application features;
  2. Can be written in many programming languages;
  3. Simplified management of software projects;
  4. Help save memory;
  5. Facilitate resource sharing;
  6. Facilitate localization of applications;
  7. Help resolve platform differences;
  8. Can be used for some special purposes. Windows makes certain features available only to DLLs.
Dependencies are created when a program or DLL uses DLL functions in other DLLs. As a result, the program is no longer independent, and if the dependency is broken, the program may encounter problems. For example, the program may not run if one of the following occurs:
  • Rely on DLLs to upgrade to the new version.
  • Fixed dependency DLL.
  • The dependent DLL is overwritten by its earlier version.
  • Removed the dependent DLL from the computer.
These operations are often referred to as DLL conflicts. If backward compatibility is not enforced, the program may not run successfully.
When creating a DLL, you can optionally specify entry point functions. When the process or
To export DLL functions, you can add function keywords to the exported DLL functions, or you can create
Regarding the call in specific situations, such as the use of Win32 API in DLL functions or the use of C ++ generated DLL for standard C language, you need to pay attention to the following situations:
If Win32 API is used, the keyword __stdcall should be used
When using a C ++ generated DLL for standard C language, the output file needs to be decorated with extern "C", otherwise it cannot be standard
HelloWorld sample DLLs and applications
At Microsoft
kernel32.dll
Low-level kernel functions. Contains functions such as memory management, task management, and resource control.
user32.dll
Functions related to Windows administration. Messages, menus, cursors, timers, communications, and most other unrealistic functions can be found here.
gdi32.dll
Graphics device interface library. Functions related to device output: Most drawing, display scene, metafile, coordinates and their font functions can be found here.
comdlg32.dll / lz32.dll / version.dll
Provides libraries for additional functions, including support for common dialogs, file compression, and version control.
comctl32.dll
A new collection of Windows controls, such as TreeView and RichTextBox, etc. This was originally made for Windows 95, but also used under NT.
mapi32.dll
Email-specific functions.
netapi32.dll
Functions to access and control the network.
odbc32.dll
ODBC-enabled DLL.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?