当前位置: 首页 > news >正文

MFC生成dll的区别

主要分三种:

A. 动态链接库(dll)

B.具有导出项的(dll)动态链接库

C.MFC动态链接库

对比项目:可以根据需要选择哪种dll方便

添加自定义导出功能Demo

1. 添加导出实现接口:

        A. 导出需要具有:__declspec(dllexport)

        B. 按照C语言的格式导出:extern "C"

下面是示例:
#ifdef __cplusplus
#define INTERFACE_API __declspec(dllexport)
#else
#define INTERFACE_API __declspec(dllimport)
#endif

class CGeneralInterface
{
public:
    CGeneralInterface();
    virtual ~CGeneralInterface();

    virtual BOOL    Open(CString csParam, CString &csErr) = 0;
    virtual void    Close() = 0;
    virtual BOOL    Write(LPCVOID pData, DWORD dwNumberOfBytesToWrite, CString &csErr) = 0;
    virtual UINT    Read(LPVOID pData, DWORD dwNumberOfBytesToRead, UINT nReadTotalTimeout, CString &csErr) = 0;
    virtual CString    GetParam(CString csParam, CString csStart, CString csEnd) = 0;
};
extern "C" INTERFACE_API CGeneralInterface* GeneralExport(void);

真正的实现,也是对外调用的接口:

CGeneralInterface* GeneralExport(void)
{
    return (CGeneralInterface*) new CGeneralCommunication();
}

对于实现类:
#ifdef   __cplusplus
extern "C" {
#endif // __cplusplus

    // 此类是从 dll 导出的
    class  CGeneralCommunication : public CGeneralInterface 
    {
    public:

         // 实现函数
    };

#ifdef __cplusplus
}
#endif //  __cplusplus
 


http://www.mrgr.cn/news/17749.html

相关文章:

  • 新版IDEA配置前进和后退、打开资源管理器等快捷按钮
  • 【JAVA开源】基于Vue和SpringBoot的新生报到网站
  • 基于STM32设计的防盗书包(华为云IOT)(216)
  • 【Spring】Spring MVC 入门(2)
  • P2024 [NOI2001] 食物链
  • Jenkins+docker+springboot 一键自动部署项目步骤
  • 网络编程核心函数
  • Linux系统练习笔记【完整版】
  • 一起学习LeetCode热题100道(66/100)
  • LIN总线CAPL函数—— 更新特定报文数据(linUpdateResponse)
  • GMeLLo:结合知识图谱的 LLM 多跳问答技术,效果显著提升
  • Java教程:入门基础【十万字详解】
  • [kylin M900]麒麟操作系统固件修改与合成
  • 【动态规划】子数组系列二(数组中连续的一段)
  • 解析淘宝商品详情API返回值中的特殊属性
  • 023、架构_资源_AZRG
  • 如何从 Mac 上清空的垃圾箱中恢复误删除的文件
  • c# fromlayout 布局中间空隙问题
  • opencv计算机视觉识别图像处理c++项目实战python网课程视频教程
  • 20240902软考架构-------软考101-105答案解析