Possible Reasons for OLE Control Registration FailureLast reviewed: October 10, 1997Article ID: Q140346 |
1.51 1.52 | 2.00 2.10 2.20 4.00
WINDOWS | WINDOWS NTkbole kbtshoot kbcode The information in this article applies to:
SUMMARYOLE controls can be registered by using Visual C++ from the Tools menu, from the Test Container provided with the Control Development Kit (CDK), or by using the regsvr or regsvr32 applications provided with Visual C++. In some cases, the registration of a control may fail; use this article to help troubleshoot the problem.
MORE INFORMATIONAll of the previously mentioned methods for registering an OLE Control use essentially the same technique. LoadLibrary() is called to load the control into memory, GetProcAddress() is called to get the address of the DllRegisterServer() function, and then DllRegisterServer() is called to register the control.
Reasons Why the Registration of a Control May Fail
Troubleshooting TechniquesIf none of the possible causes are true in your case, try the following techniques.
BOOL CTestregApp::InitInstance() { // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; }At this point, add the following code segment, which will allow you to check the return codes from LoadLibrary(), GetProcAddress(), and DllRegisterServer. #ifdef _WIN32 HINSTANCE hDLL = LoadLibrary("some.ocx"); if(NULL == hDLL) { // See Winerror.h for explaination of error code. DWORD error = GetLastError(); TRACE1("LoadLibrary() Failed with: %i\n", error); return FALSE; } typedef HRESULT (CALLBACK *HCRET)(void); HCRET lpfnDllRegisterServer; lpfnDllRegisterServer = (HCRET)GetProcAddress(hDLL, "DllRegisterServer"); if(NULL == lpfnDllRegisterServer) { // See Winerror.h for explaination of error code. DWORD error = GetLastError(); TRACE1("GetProcAddress() Failed with %i\n", error); return FALSE; } if(FAILED((*lpfnDllRegisterServer)())) { TRACE("DLLRegisterServer() Failed"); return FALSE; }#else // 16-bit HINSTANCE hDLL = LoadLibrary("regtest.ocx"); if(HINSTANCE_ERROR > hDLL) { // See LoadLibrary() help for explaination of error code. TRACE1("LoadLibrary() Failed with: %i\n", hDLL); return FALSE; } typedef HRESULT (CALLBACK *HCRET)(void); HCRET lpfnDllRegisterServer; lpfnDllRegisterServer = (HCRET)GetProcAddress(hDLL, "DllRegisterServer"); if(NULL == lpfnDllRegisterServer) { // See GetProcAddress() help for explaination of error code. TRACE("GetProcAddress() Failed"); return FALSE; } if(FAILED((*lpfnDllRegisterServer)())) { TRACE("DLLRegisterServer() Failed"); return FALSE; }#endif
|
Additional reference words: kbinf 1.51 1.52 1.52b 2.00 2.10 2.20 2.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |