How To Export Callback Functions

ID: Q83706


The information in this article applies to:


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

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 "fix" 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           : 4.00    | 3.10 3.50 3.51
Platform          : NT WINDOWS 
Issue type        : 

Last Reviewed: March 6, 1999