The Library Module Definition File

The module definition file for a library looks somewhat similar to the .DEF file for a program, but there are also significant differences between the two. For program modules, the module definition file contains a NAME statement indicating that the module is a program. For libraries, the first line is a LIBRARY statement:

LIBRARY STRLIB

This statement identifies the module as a library. The library CODE statement is the same as that used for programs:

CODE PRELOAD MOVEABLE DISCARDABLE

You can also use LOADONCALL, but for a library with a single code segment, the segment must be loaded into memory so that the initialization routine can be executed.

For a Windows program, the DATA statement indicates that the data segment is MULTIPLE, which means that each instance of the program uses the same data segment. For the STRLIB library, the data segment is marked as SINGLE, because a library can have only one instance:

DATA PRELOAD MOVEABLE SINGLE

If the library doesn't include a data segment, the DATA statement is:

DATA NONE

Notice how these directives relate to the information obtained from EXEHDR.

Because we want STRLIB to use its local heap to store its character strings, we have to give it a local heap in the HEAPSIZE statement:

HEAPSIZE 1024

This is the initial size of the local heap. Windows can expand the data segment of the library to accommodate a larger heap if one is needed. Notice there's no STACKSIZE statement in the module definition file—a library module doesn't have its own stack.

For a Windows program, the EXPORTS section of the module definition file lists all far functions within the program that can be called by Windows. Generally, this list includes at least one window procedure. For a dynamic link library, the EXPORTS section lists all far functions that can be called by programs and other library modules. This is the EXPORTS section of STRLIB.DEF:

EXPORTS AddString

DeleteString

GetStrings