The IMPORTS Statement

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. Functions and data items listed in an import library do not require an IMPORTS definition when you create a Windows DLL in the QDE; it automatically creates an import library corresponding to the DLL. If you list this import library in the project list for an application that uses the DLL, you do not need to use IMPORTS statements to import routines from the DLL.

The IMPORTS keyword marks the beginning of the import definitions, each on its own line. 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.

Summary: Syntax

IMPORTS
[[internalname=]]modulename.entry

Summary: 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.)

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.

Summary: Example

The following IMPORTS statement 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