对VC的动态加载DLL时擅自更改函数名强烈表示不满!!!!!!!!!!!
//以下是动态加载DLL的代码,语法完全正确,DLL在静态连接完全正确
typedef int (*pFun)(int,int);
pFun myfun;
HINSTANCE hmod=LoadLibrary("TrainQuery.dll"); //debug 时值为0x10000000
myfun=(pFun)GetProcAddress(hmod,"myplus"); //myfun 为null
if(myfun)
{
UpdateData(true);
m_c=myfun(m_a,m_b);
UpdateData(false);
FreeLibrary(hmod);
}
void CTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
typedef int (*pFun)(int,int);
pFun myfun;
HINSTANCE hmod=::LoadLibrary("TrainQuery.dll");
myfun=(pFun)::GetProcAddress(hmod,"_myplus@8");
if(myfun)
{
UpdateData(true);
m_c=myfun(m_a,m_b);
UpdateData(false);
FreeLibrary(hmod);
}
}
// 我用DEPENDS 看了才知道原来编译器改了我的函数名