Implementing DLLUnregisterServer 
Author Message
 Implementing DLLUnregisterServer

I have created an OLE server DLL using the MFC Wizard. Although it
contains a 'DllRegisterServer' it doesn't contain 'DllUnregisterServer.'

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



Sun, 11 May 2003 03:00:00 GMT  
 Implementing DLLUnregisterServer
I had a similar problem and fixed it by creating my own DllUnregisterServer:

STDAPI DllUnregisterServer(void)
{
 AFX_MANAGE_STATE(AfxGetStaticModuleState());
 COleObjectFactory::UpdateRegistryAll(FALSE);
 return S_OK;

Quote:
}

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


Quote:
> I have created an OLE server DLL using the MFC Wizard. Although it
> contains a 'DllRegisterServer' it doesn't contain 'DllUnregisterServer.'

> 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



Sun, 11 May 2003 03:00:00 GMT  
 Implementing DLLUnregisterServer
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

Quote:

> I had a similar problem and fixed it by creating my own DllUnregisterServer:

> 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.'

> > 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



Mon, 12 May 2003 03:00:00 GMT  
 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:

- Show quoted text -

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.'

- Show quoted text -

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



Tue, 13 May 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Implementing DllUnRegisterServer

2. DllUnregisterServer failed return code : 0x80040200

3. MFC dll appwizard, how come no DLLUnregisterServer?

4. DllUnregisterServer failed return code : 0x80040200

5. DllUnregisterServer

6. MFC and DllUnregisterServer

7. object must implement IConvertible

8. Bug? Implementing an Interface

9. Implement LDAP service provider

10. Problem implementing interface

11. Create instance of unnamed class that implements interface

12. Newbie: implementing IDisposable

 

 
Powered by phpBB® Forum Software