Implementing DllUnRegisterServer 
Author Message
 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



Fri, 11 Apr 2003 03:00:00 GMT  
 
 [ 1 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