Creating the Project

Once the source file and module-definition files have been created, use the Graphical Development Environment to create a new project.

Create a new project.

Add the source file and module-definition file to the project.

Set the program type to Windows DLL with the Project command in the Options menu.

From the Project menu, choose Build.

When the project is built, four utilities are used in the creation of the DLL:

The C Compiler

The linker

The import library creation utility

The Resource Compiler

When you build a Windows DLL, these utilities are automated under the Windows Graphical Development Environment. The following sections provide a look at the internal workings of how the utilities are used to build a DLL.

C Compiler Options

The C Compiler uses two sets of options, which are briefly described below. The following options are used to compile a Windows DLL:

The /Aw option controls the default addressing to be created by the compiler. The w option tells the compiler that the stack is not part of the default data segment, or, to put it another way, SS != DS. This causes the compiler to generate an error message when it detects the improper creation of a near pointer to an automatic variable.

The /Gw option consists of two parts. The w option requests that Windows prolog and epilog code be attached to every FAR routine. This code is used for two purposes: to assist in the establishment of the correct data segment, and to allow the memory manager to move code segments at any time during system operation.

Linker Options

The linker is passed arguments that list the object (.OBJ) files that are to be used to create the DLL.

The linker uses the .DLL extension for dynamic-link libraries. Implicitly loaded libraries must be named with the .DLL extension. An implictly loaded library is imported in the application's module-definition file rather than explicitly loaded with the LoadLibrary function. For more information on loading a DLL, see “Application Access to DLL Code” on the next page.

Other arguments list the import libraries and the static-link libraries required to create the DLL. For example: MDLLCEW.LIB and LIBW.LIB. MDLLCEW.LIB is a C run-time library which contains some DLL start-up code and C run-time library routines and math support. LIBW.LIB contains import information for KERNEL.EXE library routines.

The /NOE option is used to disable extended library searches. This inhibits the error messages created by the linker when a symbol is identified in multiple libraries.

IMPLIBW

The IMPLIBW utility creates an import library with the .LIB extension from a DLL's module-definition file. An import library is listed on the linker command line of applications that wish to use the routines in the DLL. In this way, references to DLL routines in an application can be properly resolved.

The Resource Compiler

All DLLs must be compiled with the Resource Compiler to mark them as compatible with Windows version 3.0.

You can compile a DLL with the Resource Compiler /p option. This marks the library as private to the calling application; no other applications should attempt to use the library. In the large-frame EMS memory configuration, Windows places the code and data segments of a private library above the EMS bank line. In the small-frame EMS memory configuration, Windows loads all library objects below the bank line, even if the library is private.)

The following list summarizes the difference between private and nonprivate
libraries in the two EMS memory configurations.

Nonprivate Library   Private Library  
Library
Memory Object
Small Frame Large Frame Small Frame Large Frame
Data segment Below Below Below Above
Fixed code segment Below Below Below Above
Resource Below Above Below Above
Discardable code segment Below Above Below Above