How to Use _export Keyword or DEF File EXPORTS StatementLast reviewed: August 12, 1997Article ID: Q77986 |
The information in this article applies to:
SUMMARYIn Windows 3.0 and later, the _export keyword should not be used as a general replacement for exporting functions in the EXPORTS section of a module-definition (DEF) file.
MORE INFORMATIONThe _export declarator can sometimes be used to export functions from Windows-based applications and dynamic-link libraries (DLLs); however, this method has several limitations. In the Windows environment, all callback functions must be flagged as exported to ensure that the prolog code is fixed up at load time. The fixed up prolog code works with the procedure-instance addresses returned from the MakeProcInstance() function to bind the proper data segment to the exported function when it is called. Examples of callback functions are: window procedures, dialog box procedures, and enumeration callback procedures (see Section 14.4, "Writing Exported Functions" in the "Microsoft Windows Software Development Kit Guide to Programming"). A DLL must also flag as exported any functions called from other modules. The second edition of "Programming Windows" by Charles Petzold (Microsoft Press) has a good explanation of the special Windows prolog code and the effects of listing functions in the EXPORTS section of the module- definition file (pages 280-286 and 895-896). Usually, functions are flagged as exported by listing them in the EXPORTS section of the modules' module-definition file. In addition to enabling fixup of the prolog code, exporting functions from the module-definition file provides control of the ordinal values of the exported functions. This is especially important for DLLs because existing applications that call the exported functions will not need to be relinked when the DLL is modified if the interface-function prototypes and ordinal values are not changed between versions. Specifying ordinal values also allows the Windows dynamic-link mechanism to operate faster and to use less memory. When compiling Windows-based applications and DLLs using Microsoft C version 6.0 and later, the _export keyword may be used in place of listing the function in the EXPORTS section of the module-definition file, with the following limitations:
Keywords : kb16bitonly KrDll kbhowto Version : 3.0 3.1 Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |