您的位置:首页 > 其它

DLL编写+MFC调用程序

2010-04-16 22:04 211 查看
*******************************************************************

DLL编写

extern "C" _declspec(dllexport) int Test(int i)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return i+6;

}
*******************************************************************

调用test.DLL MFC程序

typedef int(_cdecl *Connect)(int i);
HINSTANCE hinstDLL=NULL;
hinstDLL=LoadLibrary("test.dll");
if (hinstDLL)
{
Connect Proc;
Proc = (Connect)GetProcAddress (hinstDLL,"Test"); //函数检索指定的动态链接库(DLL)中的输出库函数地址。
int iValue = Proc(m_i);
FreeLibrary(hinstDLL);

char * p = new char[10];
sprintf(p,"%d",iValue);

}
else
{
AfxMessageBox("没找到dll");
}

**************************************************************
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: