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 //导出整个类
{
public:
int output(int x,int y);
};
class PO2
{
public://私有的情况下仍然不能访问的
DLL1_API int output2(int x,int y);//导出单独一个函数
};
#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 //导出整个类
{
public:
int output(int x,int y);
};
class PO2
{
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)
{
return a+b;
}
int sub(int a,int b)
{
return a-b;
}
int PO::output(int x,int y)
{
return x+y;
}
int PO2::output2(int x,int y)
{
return x*2+y;
}
#include "Dll1.h"
int add(int a,int b)
{
return a+b;
}
int sub(int a,int b)
{
return a-b;
}
int PO::output(int x,int y)
{
return x+y;
}
int PO2::output2(int x,int y)
{
return x*2+y;
}
调用程序只要包含同文件与lib库文件就可以直接使用了
#include "..\DLLPJ\Dll1.h"
。。。。。
CString str;
str.Format("%d",add(5,3));
AfxMessageBox(str);
。。。。。
CString str;
str.Format("%d",add(5,3));
AfxMessageBox(str);