这里有个VC代码:
typedef LRESULT (* DllRegisterServerProc)(void);
BOOL CRegdllDlg::TestRegCom(CString dllFileName)
{
BOOL retVal = FALSE;
HINSTANCE hDll = LoadLibrary(dllFileName);
do {
if(hDll == NULL)
{
break;
}
DllRegisterServerProc DllRegisterServer;
DllRegisterServer = (DllRegisterServerProc) GetProcAddress(hDll, "DllRegisterServer"); //这个是重点
if(DllRegisterServer == NULL)
{
break;
}
int temp = DllRegisterServer();
if(temp != S_OK)
{
break;
}
retVal = TRUE;
} while(false);
if(retVal == FALSE)
{
// MessageBox( "缺少组件", "错误", MB_OK | MB_ICONERROR);
//ShellExecute(NULL, "open", 0", NULL, NULL, SW_SHOW);
}
FreeLibrary(hDll);
return retVal;
}