0
点赞
收藏
分享

微信扫一扫

DLL的导出导入与调用

DllTest.rar

dll1.h

#ifdef DLL1_API

#else

#define DLL1_API _declspec(dllimport) 

#endif

DLL1_API int add(int a,int b);

DLL1_API int sub (int a,int b);

class DLL1_API PO //导出整个类

DLL的导出导入与调用_#include{

public:

    int output(int x,int y);

};

class PO2

DLL的导出导入与调用_#include{

public://私有的情况下仍然不能访问的

    DLL1_API int output2(int x,int y);//导出单独一个函数 

};


dll1.cpp

#define DLL1_API _declspec(dllexport)

#include "Dll1.h"

int add(int a,int b)

DLL的导出导入与调用_#include{

    return a+b;

}

int sub(int a,int b)

DLL的导出导入与调用_#include{

    return a-b;

}

int PO::output(int x,int y)

DLL的导出导入与调用_#include{

    return x+y;

}

int PO2::output2(int x,int y)

DLL的导出导入与调用_#include{

    return x*2+y;

}


调用程序只要包含同文件与lib库文件就可以直接使用了

#include "..\DLLPJ\Dll1.h"

。。。。。

 CString str;

 str.Format("%d",add(5,3));

 AfxMessageBox(str);




举报

相关推荐

0 条评论