为什么程序注册不了控件
闻缺陷则喜何志丹 《深入浅出Visual c++》书籍作者 博客专家认证 2003-05-29 10:19:43 /*BOOL RegisterOcx(LPCTSTR pszDllName)
{
HRESULT (STDAPICALLTYPE *lpDllEntryPoint)(void);
LPCSTR pszDllEntryPoint = _szDllRegSvr;//这儿有问题
BOOL bRtn;
if(FAILED(OleInitialize(NULL)))
{
AfxMessageBox("Ole initalize failed");
return false;
}
SetErrorMode(SEM_FAILCRITICALERRORS);
HINSTANCE
hLib = LoadLibraryEx(pszDllName,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
if(hLib < (HINSTANCE)HINSTANCE_ERROR)
{
AfxMessageBox("Load library failed");
bRtn = false;
goto CleanOle;
}
(FARPROC&) lpDllEntryPoint = GetProcAddress(hLib,pszDllEntryPoint);
if(lpDllEntryPoint == NULL)
{
AfxMessageBox("Failed to find dll entr point");
bRtn = false;
goto
CleanupLibrary;
}
if(FAILED((*lpDllEntryPoint)()))
{
AfxMessageBox("Failed to call entry point");
bRtn = false;
goto CleanupLibrary;
}
CleanupLibrary:
FreeLibrary(hLib);
CleanOle:
OleUninitialize();
}