从 DLL 导出函数 - 使用 DEF 文件还是 dllexport? [英] Export function from a DLL - Use DEF file or dllexport?

查看:29
本文介绍了从 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

这篇关于从 DLL 导出函数 - 使用 DEF 文件还是 dllexport?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆