为什么GetProcAddress()会失败???
创建一个正规MFC DLL,里面声明一个倒出函数如下:
_declspec(dllexport) void DoSomething()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
::AfxMessageBox("Anykey to continue...");
}
在另一个MFC单文档程序中动态链接它:
void CTestDllView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
typedef void (MyFunc)();
HINSTANCE hInstance;
VERIFY(hInstance=::LoadLibrary("f:\\MyProject\\TryDll\\TestDll\\trydll.dll"));
MyFunc *pFunc;
VERIFY(pFunc=(MyFunc*)::GetProcAddress(hInstance,"DoSometing"));
(*pFunc)();
CView::OnLButtonDown(nFlags, point);
}
总是在GetProcAddress时失败!!! 但改成隐式链接就OK, 为什么阿???