从 DLL 导出函数 - 使用 DEF 文件还是 dllexport?
模块定义 (.def) 文件提供包含有关信息的链接器导出、属性和其他有关计划的信息链接..def 文件最有用在构建 DLL 时.因为有可以使用的链接器选项而不是模块定义语句,.def 文件通常是没有必要.你也可以使用__declspec(dllexport) 作为指定导出函数的一种方式.
Module-definition (.def) files provide the linker with information about exports, attributes, and other information about the program to be linked. A .def file is most useful when building a DLL. Because there are linker options that can be used instead of module-definition statements, .def files are generally not necessary. You can also use __declspec(dllexport) as a way to specify exported functions.
http://msdn.microsoft.com/en-us/library/28d6s79h%28VS.80%29.aspx
我想知道,我们应该更喜欢 .def 方式吗?还是 dllexport 方式?
I was wondering, should we prefer .def way? or dllexport way?
模块定义 (.def) 文件为我们提供了更大的灵活性来定义数据的导出方式.
Module-definition (.def) files provide us with more flexibility to define how data going to be exported.
例如,导出的函数可以是匿名的(由序数标识),防止没有声明信息的人使用它.
For example, function exported can be anonymous (identified by ordinal) which prevent people without the declaration information from using it.
它还可以执行如下所述的 ddo 功能转发/重定向:
http://msdn.microsoft.com/en-us/library/hyx1zcd3(v=VS.80).aspx
It can also ddo function forwarding/redirection as stated below :
http://msdn.microsoft.com/en-us/library/hyx1zcd3(v=VS.80).aspx