I have a dll that's registered for com interop, so under HKLM\Software\Classes\CLSID[my guid]\InprocServer32[my version no]\Codebase it has the path of the registered dll. However, I've rearranged my folder structure so that path is no longer correct. Is there a way of unregistering that dll without putting it back, then unregistering, then removing the file again?
And what if I don't have that dll any more, or only have one with a different version number?
Different version numbers (generally) do not matter. As long as the newer DLL contains all the GUIDs which appear in the older version, it will be unregistered properly (using the new one with regasm,exe). And of course, reregistering the assembly for COM interop will properly relocate necessary registry keys.
As far as I know - all you need is to register the DLL in it's new location.
You can use MS tool oleview.exe to verify the COM registration points to the correct location.
The problem we encountered with just registering the new dll is when it's got a lower version to the previously-registered one. You end up with this in the registry:
HKCR\MyLib.MyClass\CLSID:(Default)=<my guid>
and
HKCR\CLSID\<my guid>:Assembly=<string containing version number>
and
HKCR\CLSID\<my guid>\InprocServer32\<version number>\ ... more details
I think the runtime will try to load the assembly identified in HKCR\CLSID\<my guid>:Assembly
, so you want to try to unregister that one if possible.
This isn't an answer about how to unregister it, but if you can't unregister that I've found it useful to get in there and remove the key for the version number you no longer have, and probably update the Assembly
value manually if you dare.