dll导出函数问题

gooore 2010-06-08 05:12:08

请教怎么将下面这个导出类,整形变量,和一个函数写成一个def文件?


// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the WINAPI_DLL_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// WINAPI_DLL_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef WINAPI_DLL_EXPORTS
#define WINAPI_DLL_API __declspec(dllexport)
#else
#define WINAPI_DLL_API __declspec(dllimport)
#endif

// This class is exported from the WinAPI_DLL.dll
class WINAPI_DLL_API CWinAPI_DLL {
public:
CWinAPI_DLL(void);
// TODO: add your methods here.
};

extern WINAPI_DLL_API int nWinAPI_DLL;

WINAPI_DLL_API int fnWinAPI_DLL(void);


...全文
122 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
gooore 2010-06-10
  • 打赏
  • 举报
回复
如果用宏导出的话,名字被编译器处理了。用VB声明API,还要用dumpbin看一下处理后的名字,比如

'Custom Dll
Private Declare Function fnWinAPI_DLL Lib "WinAPI_DLL.dll" Alias "fnWinAPI_DLL@@YAHXZ" () As Long


用def文件后就好了。两个疑问的地方,

1. 用def可以导出变量,但是不知道可不可以被vb声明并调用,像声明api函数一样
2. 不知道导出的类可不可以被vb所用,该怎么用。如果不能用def文件导出类,那是不是也需要用dumpbin查看名字?

[Quote=引用 2 楼 oyljerry 的回复:]
直接导出类,def只能导出函数
[/Quote]
zhengjiankang 2010-06-10
  • 打赏
  • 举报
回复
这个类已经是导出类了
// This class is exported from the WinAPI_DLL.dll
你没看到这个注释么?
外部使用直接包含此头文件 然后就可以用了
magic7004 2010-06-10
  • 打赏
  • 举报
回复
做成COM吧...
qianhe_he 2010-06-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 visualeleven 的回复:]
http://blog.firnow.com/Synthesis/archive/2010/2/27/B4F37B4C-B704-4B5E-9517-5216D6CE8166.html
讲的比较详细。。。
[/Quote]
你很活跃啊
zhou1xp 2010-06-09
  • 打赏
  • 举报
回复
def文件导出类不知道行不行,函数到时很容易
icefairy 2010-06-09
  • 打赏
  • 举报
回复
mark
oyljerry 2010-06-09
  • 打赏
  • 举报
回复
直接导出类,def只能导出函数
  • 打赏
  • 举报
回复
我是来关注的!

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧