Name
Exports Keyword
Syntax
exportsSubroutine
,Subroutine
nameIdentifier
,Subroutine
indexConstant
,Subroutine
indexConstant
nameIdentifier
, ...;
Description
The exports
declaration lists the names or
signatures of subroutines to be exported from a DLL. You can declare
subroutines to export in any unit or in the library’s project
file.
If a subroutine is overloaded, you can specify which subroutine to
export by including the subroutine’s arguments in the
exports
declaration. You can export multiple
overloaded subroutines, but make sure the caller is able to identify
which one it wants to call by assigning a unique name to each
one.
By default, the subroutine is exported under its own name, but you can specify a different name or an index number. If you do not supply an index, Delphi automatically assigns one.
Tips and Tricks
You can use the
index
andname
directives for the same exported routine (in that order).Delphi does not check for duplicate indices, so be careful.
Delphi 5 does not allow the
index
directive for overloaded subroutines.
Example
unit Debug; interface // Simple debugging procedures. Debug messages are written to // a debug log file. You can link this unit into an application, // or use in a DLL. See the External Directive for an example // of how an application can use these procedures from a DLL. procedure Log(const Msg: string); overload; procedure Log(const Fmt: string; const Args: array of const); overload; procedure SetDebugLog(const FileName: string); function ...
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.