3
votes

I'm refering to this thread

How do I install both 32-bit and 64-bit versions of a COM DLL and "auto-select"?

we have exactly the same situation. A namespace extension Dll 32bit and 64bit with same CLSID App ID out of the same project. Now registering those two Dlls works flawlessly. Unregistering brings up some errors. The first unregister works but the second fails. Because I think windows (?) thinks the Dll has already been deregistered...

Do the two Dlls need different CLSIDs and/or App IDs???

Kind regards, Michael

EDIT: here's what the DllUnregisterServer does:

STDAPI DllUnregisterServer(void){

    _AtlModule.UpdateRegistryAppId(FALSE);
    HRESULT hRes2 = _AtlModule.UnregisterServer(TRUE);
    if (hRes2 != S_OK)
        return hRes2;
    AFX_MANAGE_STATE(_afxModuleAddrThis);

    if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
        return ResultFromScode(SELFREG_E_CLASS);

     return NOERROR;
}
2
I guess "some errors" should give you the idea of what goes wrong. - sharptooth
ok in detail it gives me error code 0x8002801c - Jesse James

2 Answers

1
votes

Windows doesn't care - it's regsvr32 that performs the registration. You use the 32-bit version of regsvr32 for 32-bit DLLs and the 64-bit version for 64-bit DLLs.

Both version just load the DLL, find DllRegisterServer()/DllUnregisterServer() entry point, invoke it and observe the returned value. Whatever goes inside is not regsvr32 business.

Your problem is one of those functions works wrong. You have to debug this. A good start is to use Process Monitor utility to observe what registry accesses are performed and whether they are what you expect.

0
votes

Adding more info to the answer from sharptooth, if you are unregistering your dll programmatically by excecuting regsvr32, then you might be calling the wrong regsvr32 file. You need to make sure you call regsvr32 from System32 for unregistering your 64 bit dll and regsvr32 from SysWow64 for unregistering the 32 bits version. You can p/Invoke the funcion GetSystemWow64Directory for retrieving the SysWow64 folder location.