Callback Functions in Multiple Instance Applications

Last reviewed: July 23, 1997
Article ID: Q102871
3.00 3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows, versions 3.0 and 3.1

The following are some requirements for callback functions in multiple instance applications when compiling with Microsoft C version 7.0 or C version 8.0 for protected-mode-only Win16:

  • Callback functions must be branded with the "__export" keyword. The compiler switches -GA -GEf force all far functions in a module to be __export. The optimum method is to add the __export keyword to the particular callback function and not use the -GEf switch. Example:

          BOOL CALLBACK __export CallBackProc
    
  • Callback functions called via MakeProcInstance() must load DS from the value in AX. Use the compiler switch -GA with the -GEa switch to generate prolog code to load DS from the value in AX on all __export functions. The default for -GA is load DS from SS, which is not a valid assumption in callbacks. The code when loaded into memory should have three NOPs instructions at __export function entry points. Check with your favorite debugger that can show mixed/asm view once the module is loaded into memory.
  • Callback functions must have an export record in the EXE header. The classic method is to list the function in the EXPORTS section of the module's .DEF file. The callback's module can be built with the - GA -GEe switches to place an export record in the .OBJ at compile time for all __export functions.
  • Callback functions must assume SS != DS, DS not loaded on function entry. Compile with -Aw memory model customizer to have correct code generated.
  • Callback functions must not call C Run-time library code contained in the application (xLIBCyW.LIB) libraries. They assume SS == DS.


Additional reference words: 3.10
KBCategory: kbprg
KBSubcategory: KrTsksIns
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.