dll导出类如何动态加载?
我的导出类是CCommunity;在我使用的时候。pFunction=(CCommunity*)::GetProcAddress(hDLL,"CCommunity");
获得的pFunction总是为0x000000,为何呢?不能这么用吗?那用设么方法?
HINSTANCE hDLL;
//进程中的每个DLL由唯一的32位字节HINSTANCE值进行标志。
CCommunity* pFunction;
hDLL=::LoadLibrary("..\\lib\\Erric_T20_Commu.dll");//加载动态链接库dll文件;
if(hDLL)
AfxMessageBox("MyDll.dll已经成功加载!");
else
{
AfxMessageBox("没有找到MyDll.dll,请先编译好dll.");
return E_ERROR;
}
pFunction=(CCommunity*)::GetProcAddress(hDLL,"CCommunity");
CString test = "";
pFunction->DisConnect();
::FreeLibrary(hDLL);//卸载dll文件;
return E_SUCCESS;