注:本文介绍MFC中的dll生成与调用方法
1.建立一个MFC项目MfcDll,并利用类向导添加一个类DllWin
2.添加声明导出类
格式 class declspec (dllexport) 类名:继承表
class _declspec(dllexport) DllWin : public CButton
{
// Construction
public:
DllWin();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{
{AFX_VIRTUAL(DllWin)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~DllWin();
// Generated message map functions
protected:
//{
{AFX_MSG(DllWin)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
3.为了看调用效果,在构造函数中加入一名话
DllWin::DllWin()
{
AfxMessageBox("调用