To produce Windows-format executable files, you use Microsoft Segmented Executable Linker (LINK), which is supplied with CL. Unlike normal C applications, Windows applications require a module-definition (.DEF) file for linking. This file must do the following:
Define a name for the application.
Mark the application as a Windows application.
Specify certain attributes of the application, such as whether a data segment is movable in memory.
List and name any callback functions in the application.
Following is an example of a module-definition file:
NAME Generic ;application's module name
DESCRIPTION 'Sample Microsoft Windows Application'
EXETYPE WINDOWS ;required for all Windows applications
STUB 'WINSTUB.EXE' ;The "stub" displays an error message if
;the application is run without Windows.
CODE PRELOAD MOVEABLE ;code can be moved in memory
;DATA must be MULTIPLE if the program can be invoked more than once.
DATA MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120 ;recommended minimum for Windows applications
;All functions that will be called by any Windows function
;MUST be exported.
EXPORTS
MainWndProc @1 ;name of window-processing procedure
AboutDlgProc @2 ;name of About processing procedure
To link a Windows application, you specify the name of each object file created by the compiler, the name of the Windows import library, the name of the module-definition file, and other options and files. Following is a typical LINK command:
link /nod generic, , , slibcew libw, generic.def
For more information about LINK and the module-definition file, see Microsoft Windows Programming Tools.