13.4 The LIBRARY Statement

The LIBRARY statement identifies the executable file as a DLL. It can also specify the name of the library and the type of library-module initialization required. The NAME or LIBRARY statement must precede all other statements. If LIBRARY is specified, the NAME statement cannot be used. If neither is used, the default is NAME.

Syntax

LIBRARY [[libraryname]] [[initialization]] [[PRIVATELIB]]

Remarks

The fields can appear in any order.

If libraryname is specified, it becomes the name of the library as it is known by OS/2 or Windows. This name can be any valid filename. If libraryname contains a space, begins with a nonalphabetic character, or is a reserved word, surround the name with double quotation marks. The name cannot exceed 255 characters. If libraryname is not given, the base name of the DLL file becomes the name of the library.

If initialization is specified, it determines the type of initialization required. The initialization field can take one of the following values:

Value Description

INITGLOBAL The default. The library-initialization routine is called only when the library is initially loaded into memory.
INITINSTANCE The library-initialization routine is called each time a new process gains access to the DLL. This keyword applies only to OS/2.

If PRIVATELIB is specified, it tells Windows that only one application may use the DLL.

Example

The following example assigns the name calendar to the DLL being defined and specifies that library initialization is performed each time a new process gains access to calendar:

LIBRARY calendar INITINSTANCE