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  // 导出整个类
{
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;
}

调用程序只要包含同文件与lib库文件就可以直接使用了
#include  " ..\DLLPJ\Dll1.h "
。。。。。
 CString str;
 str.Format(
" %d " ,add( 5 , 3 ));
 AfxMessageBox(str);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值