What are DLL files (.dll)



DLL Files in Windows- What Are They?


Dynamic Link Library (DLL) files are an essential part of the Windows operating system. Although they are ubiquitous, most PC users neither know nor care what these files do. Nonetheless, a little understanding of the role that DLL files play can make the computer a little less of a mystery box. Only programmers and computer technicians need to know any of the gory details of the structure and function of a DLL, but these files are so important that all of us should know a few simple facts about them. Here is some information for the non-technical PC user.


What Do DLL Files Do?


A DLL file is indicated by the extension DLL in its name. Microsoft gives several definitions of a DLL but the one that I think has the least jargon is this:
"A Dynamic Link Library (DLL) is a file of code containing functions that can be called from other executable code (either an application or another DLL). Programmers use DLLs to provide code that they can reuse and to parcel out distinct jobs. Unlike an executable (EXE) file, a DLL cannot be directly run. DLLs must be called from other code that is already executing."
Another way of putting it is that DLL files are like modules that can be plugged into different programs whenever a program needs the particular features that come with the DLL. The original concept behind DLL files was to simplify things. It was recognized that there were many functions common to a lot of software. For example, most programs need to create the graphical interface that appears on the screen. Instead of having to contain the code to create the interface themselves, programs call on a DLL for that function. The idea is to have a central library where everyone can obtain the commonly used functions, as they are needed. This cuts down on code, speeds things up, is more efficient, etc. They are called dynamic links because they are put to use only when a program calls on them and they are run in the program’s own memory space. More than one program can use the functions of a particular DLL at the same time.
Parenthetically, I have to say that the software developers (not least of all, Microsoft) have strayed from the path of keeping things simple. A computer today may contain a thousand or more different DLL files. Also, Microsoft seems to tinker endlessly with DLL files, giving rise to many different versions of a file with the same name, not all compatible. Microsoft maintains a database with information about various DLLs to help with version conflicts.
There are several very important DLLs that contain a large number of the basic Windows functions. Since they figure so importantly in the workings of Windows, it is worth noting their names.


Examples of Important DLL files:


COMDLG32.DLL
Controls the dialog boxes
GDI32.DLL
Contains numerous functions for drawing graphics, displaying text, and managing fonts
KERNEL32.DLL
Contains hundreds of functions for the management of memory and various processes
USER32.DLL
Contains numerous user interface functions. Involved in the creation of program windows and their interactions with each other It is the common use of these types of DLLs by most programs that ensures that all applications written for Windows will have a standard appearance and behavior. This standardization was a big factor in the rise of Windows to dominance of the desktop computer. Anyone who was working with computers in the days of DOS will remember that every program had its own interface and menus.
Error Messages involving DLLs
PC users often see DLLs (especially the ones mentioned above) mentioned in error messages. One might conclude, therefore, that something is always going wrong with DLLs. Very often, however, it is not the DLL itself that is at fault. DLL files figure prominently in the error messages when something in the system goes awry because they are involved in the most basic processes of Windows. They are in effect the messenger of trouble, not the actual trouble. It is beyond our scope to discuss any details of error messages but there are substantial references on interpreting them. One is at James Eshelman's site.
Using Regsvr32.exe to Register DLLs
First, let it be clear that the important system file regsvr.exe should not be confused with the file regsrv.exe that is used by certain worms and Trojans.
In order for a DLL to be used, it has to be registered by having appropriate references entered in the Registry. It sometimes happens that a Registry reference gets corrupted and the functions of the DLL cannot be used anymore. The DLL can be re-registered by opening Start-Run and entering the command regsvr32 somefile.dllThis command assumes that somefile.dll is in a directory or folder that is in the path. Otherwise, the full path for the DLL must be used. A DLL file can also be unregistered by using the switch "/u" as shown below.regsvr32 /u somefile.dllThis can be used to toggle a service on and off.