




















基于非mfc的组件的主函数为:
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point

extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_TESTALib);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE; // ok
}

/////////////////////////////////////////////////////////////////////////////
基于mfc的组件主函数为:
/////////////////////////////////////////////////////////////////////////////
class CTestBApp : public CWinApp
{
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestBApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL

//{{AFX_MSG(CTestBApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CTestBApp, CWinApp)
//{{AFX_MSG_MAP(CTestBApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CTestBApp theApp;

BOOL CTestBApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance, &LIBID_TESTBLib);
return CWinApp::InitInstance();
}

int CTestBApp::ExitInstance()
{
_Module.Term();
return CWinApp::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////
如果需要从非mfc组件改成mfc组件,可以参考文章:HOWTO: 给 ATL 项目添加 MFC 支持,以下为链接地址
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。