There’s a good chance most .NET developers don’t have to deal with this much anymore, but for those stuck in VB6, you might know the pain of cleaning up after ActiveX executables and DLLS.
If everything goes as planned, it’s trivial. For ActiveX DLLs, you can just use regsvr32 with the /u switch, like so:
regsvr32 /u dllFile.dll
For ActiveX executables, you use the /unregserver argument for EXE itself, like so:
ActiveXFile.exe /unregserver
Each ActiveX file has a class ID (CLSID) that uniquely identifies that file in the registry. When you unregister the ActiveX library with one the previous commands, all references to the library are removed from the registry. This is important if you’d like to update an ActiveX library that has had it’s CLSID changed. Normally, you’d just unregister the old library (using the old file), remove the old file, then copy in the new file and register it.
Lil’ Orphan Annie
So what happens if the old library file has been deleted? You’re stuck with all those old keys in the registry, and often times that will prevent the new from registering properly!
It just so happens I was working with a company that had a problem like this. Their product had several ActiveX exes and DLLS, and more often than not, when trying to update a client’s files, someone would forget to unregister the old libraries before removing them, so we found ourselves stuck in this mess quite often.
To figure out how to fix this, I decided to figure out exactly what happened when an ActiveX library is registered, so I could undo the changes. I did some research and concluded that when an ActiveX library is registered, the only thing on the system that changes is that several keys are added to the registry. There are several programs (mostly for installers) that will help you discover exactly how an installation has affected your system, but I wanted to try a free way. This is where a simple but irreplaceable tool came into play: the diff tool.
Visual diff tools rock!
Diff tools compare two text-based files (or blocks of text) and visually show you how those files are different. It’s an absolute must-have for programmers…when combined with a revision control software product like SVN, git, or Source Save, you can easily compare how a text file has changed since it was last ‘checked-in’. There are plenty of good ones out there…I’d recommend checking out WinMerge. It’s fast, free, looks good, and integrates nicely with TortoiseSVN.
So how is WinMerge going to help us here? Well, fortunately the Windows Registry Editor (regedit) provides an option to export the entire registry into a text file! So, discovering how your registry has changed after an operation is as simple as:
- Taking a snapshot of your registry (export to text file)
- Applying the change (registering your ActiveX DLL)
- Taking another snapshot of your registry (export to different text file)
- Comparing the two text files to spot the differences (Use WinMerge or other diff tool)
On to the next adventure
It’s ridiculously simple, but it works great, and it’s free. You’ll learn a lot about how much your registry is being used constantly by the OS and your running programs.
Now that we know which registry entries have changed, we can look for patterns and figure how to remove all traces of an ActiveX library from the registry just by knowing it’s original path. I’ll cover that topic in a future post.
I hope this can help out some poor soul still using VB6 ActiveX libraries!


