首页 > 编程 > C++ > 正文

C++ Dll 导出类

2019-11-08 18:40:14
字体:
来源:转载
供稿:网友

        首先,新建 Test_cpp_define.h    头文件。

                  

#PRagma once# ifndef Test_CPP_API#  ifdef Test_CPP_DLL#   define Test_CPP_API __declspec(dllexport)#  else#   define Test_CPP_API __declspec(dllimport)#  endif# else#  define Test_CPP_API# endif

         在Dll  编译项中定义宏  Test_CPP_DLL  ,在需要导出 的类前 添加  Test_CPP_DLL  即可。

             例如:

class Test_CPP_API CMarkDataMng

             完整导出类 代码如下:

           

#pragma once#include "../Test_cpp_define.h"class CMarkData;class Test_CPP_API CMarkDataMng{   public:   private:}   这即为 导出类头文件,在 需要引用的程序中包含此头文件即可. 是不是 So Easy 呀!~~~~~~~~~


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选