|
好!
这是扩展MFC的动态库(平台已经支持MFC)
#include "stdafx.h"
#include
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static AFX_EXTENSION_MODULE EvcdllDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("EVCDLL.DLL Initializing!\n");
if (!AfxInitExtensionModule(EvcdllDLL, (HINSTANCE)hInstance))
return 0;
new CDynLinkLibrary(EvcdllDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("EVCDLL.DLL Terminating!\n");
AfxTermExtensionModule(EvcdllDLL);
}
return 1; // ok
}
__declspec(dllexport) int sum(int a,int b)
{
return a+b;
}
这是调用代码(在工程project-setting-link中已经设置链接动态库的LIB)
__declspec(dllimport) int sum(int a,int b);
void CEvcdlgDlg::OnButton1()
{
m_iSum=sum(3,4);
}
就是这个样子,不知道为什么不能运行!!
我尝试改成VC下,是可以的,为何在WINCE下不行呢? |
|