
Implementing DLLUnregisterServer
Neil,
That's strange because this is pretty much what the app wizard gennerates
when you create an MFC ActiveX App:
// 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:
}
The first call unregisters the type lib and the second one calls the
UpdateRegistryAll(FALSE). I'll take a look at Code Guru and see what they
have to say.
Thanks,
-Rob
Quote:
> Rob,
> I found some code on the codeguru website last night, but thanks for the
> response.
> Unfortunately, one of the things they point out there is that
> COleObjectFactory::UpdateRegistryAll(FALSE); calls
> COleObjectFactory::UpdateRegistry(FALSE); which does nothing!
UpdateRegistry
> only works when the parameter passed in is TRUE.
> Neil
> > I had a similar problem and fixed it by creating my own
DllUnregisterServer:
Quote:
> > STDAPI DllUnregisterServer(void)
> > {
> > AFX_MANAGE_STATE(AfxGetStaticModuleState());
> > COleObjectFactory::UpdateRegistryAll(FALSE);
> > return S_OK;
> > }
> > It is the FALSE in the UpdateRegistryAll call that does the unregister.
> > You will also need to add the function to the DEF file so that it gets
> > exported properly:
> > EXPORTS
> > ; Explicit exports can go here
> > DllCanUnloadNow PRIVATE
> > DllGetClassObject PRIVATE
> > DllRegisterServer PRIVATE
> > DllUnregisterServer PRIVATE
> > Regards,
> > -Rob
> > > I have created an OLE server DLL using the MFC Wizard. Although it
> > > contains a 'DllRegisterServer' it doesn't contain
'DllUnregisterServer.'
Quote:
> > > Is there an easy way to implement this? Or have I got to look at what
> > > RegisterServer is entering in the registry and then implement my own
> > > reverse process? If so are there any well known gotcha's to avoid?
> > > TIA,
> > > Neil