The IMPORTS statement defines the names and locations of functions and data items to be imported (usually from a DLL) for use in the application or DLL. A definition is required for each function or data item being imported. This statement is an alternative to resolving references through an import library created by the IMPLIB utility; functions and data items listed in an import library do not require an IMPORTS definition.
The IMPORTS keyword marks the beginning of a section of import definitions. Multiple definitions must be separated by one or more spaces, tabs, or newline characters. The IMPORTS keyword must appear once before the first definition on the same or preceding line and can be repeated before each additional definition. IMPORTS statements can appear more than once in the file.
Syntax
IMPORTS
[[internalname=]]modulename.entry
Remarks
The internalname specifies the function or data-item name as it is used in the importing application or DLL. Thus, internalname appears in the source code of the importing program, while the function may have a different name in the program where it is defined. By default, internalname is the same as the entry name. An internalname is required if entry is an ordinal value.
The modulename is the filename of the exporting application or DLL that contains the function or data item.
The entry field specifies the name or ordinal value of the function or data item as defined in the modulename application or DLL. If entry is an ordinal value, internalname must be specified. (Ordinal values are set in an EXPORTS statement.) If the function or data item is in a C++ modeule, entry must be specified as a decorated name. For information on decorated names, see Appendix B.
Note:
A given symbol (function or data item) has a name for each of three different contexts. The symbol has a name used by the exporting program (application or DLL) where it is defined, a name used as an entry point between programs, and a name used by the importing program where the symbol is used. If neither program uses the optional internalname field, the symbol has the same name in all three contexts. If either of the programs uses the internalname field, the symbol may have more than one distinct name.
Example
The IMPORTS statement that follows defines three functions to be imported: SampleRead, SampleWrite, and a function that has been assigned an ordinal value of 1. The functions are found in the Sample, SampleA, and Read applications or DLLs, respectively. The function from Read is referred to as ReadChar in the importing application or DLL. The original name of the function, as it is defined in Read, may or may not be known and is not included in the IMPORTS statement.
IMPORTS
Sample.SampleRead
SampleA.SampleWrite
ReadChar = Read.1