DLL 导入和导出函数DLL Import and Export Functions

Microsoft 专用Microsoft Specific

有关本主题的最完整且最新的信息可在 dllexport、dllimport 中找到。The most complete and up-to-date information on this topic can be found in dllexport, dllimport.

dllimport 和 dllexport 存储类修饰符是 C 语言的 Microsoft 专用扩展。The dllimport and dllexport storage-class modifiers are Microsoft-specific extensions to the C language. 这些修饰符显式定义了 DLL 与其客户端(可执行文件或另一个 DLL)的接口。These modifiers explicitly define the DLL's interface to its client (the executable file or another DLL). 如果将函数声明为 dllexport,则不再需要模块定义 (.DEF) 文件。Declaring functions as dllexport eliminates the need for a module-definition (.DEF) file. 还可以将 dllimport 和 dllexport 修饰符用于数据和对象。You can also use the dllimport and dllexport modifiers with data and objects.

dllimport 和 dllexport 存储类修饰符必须与扩展特性语法关键字 __declspec 一起使用,如以下示例中所示:The dllimport and dllexport storage-class modifiers must be used with the extended attribute syntax keyword, __declspec, as shown in this example:

#define DllImport   __declspec( dllimport )  
#define DllExport   __declspec( dllexport )  

DllExport void func();  
DllExport int i = 10;  
DllExport int j;  
DllExport int n;  

有关扩展的存储类修饰符的语法的特定信息,请参阅扩展的存储类特性For specific information about the syntax for extended storage-class modifiers, see Extended Storage-Class Attributes.

结束 Microsoft 专用END Microsoft Specific

另请参阅See Also

C 函数定义C Function Definitions