EXPORTS

EXPORTS definitions

This statement makes one or more definitions available as exports to other programs.

EXPORTS marks the beginning of a list of export definitions. Each definition must be on a separate line. The EXPORTS keyword can be on the same line as the first definition or on a preceding line. The .def file can contain one or more EXPORTS statements.

The syntax for an export definition is:

entryname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA]

The optional NONAME allows you to export by ordinal only.

The optional keyword PRIVATE prevents entryname from being placed in the import library generated by LINK. It has no effect on the export in the image also generated by LINK.

The optional keyword DATA specifies that an export is data, not code. When you use PRIVATE and DATA for the same export, PRIVATE must preceed DATA.

There are three methods for exporting a definition, listed in recommended order of use:

  1. The __declspec(dllexport) keyword in the source code
  2. An EXPORTS statement in a .def file
  3. An /EXPORT specification in a LINK command

All three methods can be used in the same program. When LINK builds a program that contains exports, it also creates an import library, unless an .exp file is used in the build.

The following is an example EXPORTS section,

EXPORTS
   DllCanUnloadNow      @1     PRIVATE   DATA
   DllWindowName = Name        DATA
   DllGetClassObject    @4 NONAME   PRIVATE
   DllRegisterServer    @7
   DllUnregisterServer