
Implementing DllUnRegisterServer
I have an MFC DLL that was created using app wizard. Inside this DLL, I
created a COM object (derived from CCmdTarget) that was defined as creatable
using a ProgID. The problem is that when someone tries to uninstall the
DLL, the COM object does not uninstall. The CWinApp derived class created
by the wizard does not implement & export the DllUnregisterServer function.
It does implement the DllRegisterServer as follows:
// by exporting DllRegisterServer, you can use regsvr.exe
STDAPI DllRegisterServer(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
COleObjectFactory::UpdateRegistryAll();
return S_OK;
Quote:
}
When you create a project in VC++ using the ActiveX Control app wizard it
does create a DllUnregisterServer function for you. This is what you get:
////////////////////////////////////////////////////////////////////////////
/
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
AFX_MANAGE_STATE(_afxModuleAddrThis);
if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
return ResultFromScode(SELFREG_E_TYPELIB);
if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
return ResultFromScode(SELFREG_E_CLASS);
return NOERROR;
Quote:
}
////////////////////////////////////////////////////////////////////////////
/
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
AFX_MANAGE_STATE(_afxModuleAddrThis);
if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
return ResultFromScode(SELFREG_E_TYPELIB);
if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
return ResultFromScode(SELFREG_E_CLASS);
return NOERROR;
Quote:
}
///////////////////////////////////////////////////////////////////////////
I wanted to get some suggestions on the best way to implement
DllUnregisterServer for my situation where you start off with just an MFC
Dll. Can I just call:
COleObjectFactoryEx::UpdateRegistryAll with FALSE as a parameter as in
the ActiveX Control project?
Thank you,
-Rob