Vc dll中导出类的方法

class _declspec(dllimport) circle
class _declspec(dllimport) circle
#pragma comment("lib", "dll.lib")
就用这三句话轻松搞定,什么def文件都他妈的狗屁

大家可以下载源代码http://www.84250.com/BLOG/attachments/month_200512/14_230909_1xp4Vcdll.rar

#include "windows.h"

class _declspec(dllimport) circle //导出类circle
{
public:
  circle();
  int getnum();
  void setnum(int arg);
private:
  int num;
};

circle::circle()        {num=2;}
int circle::getnum()      {return num;}
void circle::setnum(int arg)  {num=arg;}

/**************************************************
dllMain函数可有可无,因为它并不做什么工作,系统会自动生成的
***************************************************/
BOOL APIENTRY DllMain( HANDLE hModule,
           DWORD ul_reason_for_call,
           LPVOID lpReserved
           )
{
return TRUE;
}


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


class _declspec(dllimport) circle //导出类circle
{
public:
  circle();
  int getnum();
  void setnum(int arg);
private:
  int num;
};

void CExeDlg::OnButton1()
{
  circle a;
  CString temp;
  temp.Format("%d",a.getnum());
  MessageBox(temp);
  
  a.setnum(1000);
  temp.Format("%d",a.getnum());
  MessageBox(temp);  
}

普通win32 DLL ,用__declspec(dllexport)修饰导出类
或者建立一个MFC 扩展DLL

做成MFC扩展DLL,然后在导出的类前面加AFX_EXT_CLASS
和一般的dll一样,仅是
在类前面加上AFX_EXT_CLASS ,如
class AFX_EXT_CLASS Cxx : public CObject
{
.....
};
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值