Microsoft KB Archive/83706

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * Microsoft Windows NT, versions 3.1, 3.5, 3.51, 4.0
 * Microsoft Windows 95, version 4.0

-

SUMMARY
It is not necessary for Win32-based applications to export callback functions. Windows versions 3.1 and earlier (Win16) need callback functions primarily for fixing references to global data and ensuring that EMS memory is not paged out. Neither of these situations applies to the Windows NT operating system.

MORE INFORMATION
Exports are necessary for any function that must be located at either


 * Run time via GetProcAddress(dynamic linking)

-or-
 * Load time via an import library (static linking)

Both of these linking methods require that the name or ordinal number of the export be known and that their names (or ordinal numbers) be present in the executable's exported entry table. This enables Windows to determine the addresses at run time.

Static linking is done by the loader, which performs this lookup for all of the imported entry points that an executable needs (normally by ordinal number). In dynamic linking, the system scans by ordinal number or by name through the DLL (Dynamic Link Library) exports table.

In Win16, exported entries are automatically fixed by the linker to adjust to the appropriate data segment. Exporting entries on Win32 just adds them to the module's exported names and ordinal numbers table; the linker does not need to &quot;fix&quot; them. For code compatibility with Win16, you may want to continue to use MakeProcInstance and export all callbacks. This macro does nothing on Windows NT.

In short,                    On Windows                       Win32 ---     -   Callbacks        Export or use MakeProcInstance   Use address of fn   GetProcAddress   Must export                      Must export Static linking  Must export                      Must export Additional query words: 3.10 3.50

Keywords         : kbDLL kbKernBase kbGrpKernBase Version          : winnt:3.1,3.5,3.51,4.0 Platform         : winnt Issue type       :
 * }