Dynamic-link library (Windows)

A dynamic-link library (DLL) is a particular kind of NE or PE file. It is a Microsoft Windows method of having separately-compiled modular routines able to be loaded at run-time when needed by programs. The various versions of Windows include a large number of such files used by system programs and other software, and third-party software is likely to include other files of this sort, some specific to one program and some shared by multiple programs.

The normal file extension is .dll, but .ocx is also found for libraries containing ActiveX controls, and .drv for system drivers (of an old legacy format). Additionally, some other formats such as FON use similar format, but limited to particular sorts of content rather than the full range of executable program routines and resource data which can be stored in a DLL.

Discussion
There are lots of problems and pitfalls related to these files. Programs may install different versions of the same DLL on top of the previously existing one, possibly breaking other software that depends on the other version and is incompatible with the one just installed. Or if a program's installer avoids this problem by installing its DLLs in a different directory from others of the same name (which might be different versions of a DLL or totally different ones that just happened to be named the same), a system might still have a poorly-set path variable that causes the wrong version to be used, and trying to untangle which file is supposed to be used by which program is a difficult task even for a technically knowledgeable user. Then when you uninstall a program, perhaps it will delete all its DLLs (perhaps breaking a different program that also uses them), or perhaps it will leave them in place (even if no other program uses them), contributing to the mess and bloat that plagues Windows PCs in their old age.

If a program crashes due to lack of a required DLL, perhaps you'll Google it and run into a site that purports to make it available for download... but then tries to push you into downloading and installing their own spyware/adware as well. Watch out! You're best going to the appropriate software manufacturer's site (e.g., Microsoft's if it's a part of the Windows system, or the third-party software company for the package that the DLL is connected with).

NE
The byte at offset 13 of the extended header is a field named Application Flags. For NE DLL files, it has the 0x80 bit set.

Refer to New Executable for identification of NE format.

Note that this identification logic may not be perfect, depending on your definition of what is and is not a DLL (e.g. is a device driver, or an Icon library, a DLL?).

PE
The 16-bit integer at offset 22 of the extended header (or, offset 18 of the COFF File Header) is a field named Characteristics. For PE DLL files, it has the 0x2000 bit set.

Refer to Portable Executable for identification of PE format.

Specifications
Refer to New Executable and Portable Executable.

Sample files

 * https://telparia.com/fileFormatSamples/executable/dll/

Links

 * Dynamic-link library (Wikipedia)
 * Definition and Explanation of a .DLL file
 * Dynamic-Link Libraries
 * DLL tutorial
 * Wikibooks: Programming Dynamic Link Libraries
 * Everything You Ever Wanted to Know about DLLs (video)