It’s been a while since the last post and now Windows makes headlines. At least here. But enough of the whining and back to business.
The DLL hell problem. Well, everybody using Windows sooner or later became acquainted with this nice place. Nowadays the hell is not as hot anymore because programs are nice and install DLL’s in the program directory and Windows looks there first. Plus, it has a lot of automagic mechanisms that try to find the correct DLL.
But what if you have two pieces of software in the same directory and they need the same DLL,… but in different versions. You might think you are in hell, but fear not, there is a solution.
There are multiple ways for Windows to load a DLL and in this particular case the standard mechanisms fail. So we have to nudge Windows into the right direction. And the best way to do that is to dive into the registry, quel surprise.
As a first step you have to create two separate folders where the DLL’s will reside. Lets call them LibA and LibB. Now we have to force Windows to use the correct DLL for the correct executable. This is done by adding a sub key to the registry to the following key:
HKEY_LOCAL_MACHINE\SOTWARE\Microsoft\Windows\CurrentVersions\App Paths
This new sub key needs to get as the name the name of the .exe file, like TestApp1.exe or TestApp2.exe.
Into the Standard value Windows needs to get again the executable but this time with the full path, like “C:\Program Files\TestApp\TestApp1.exe”.
And last, but not least, you create for each of these keys a new string value with the name Path. After you assign the path to the DLL folder to that string value (for instance C:\Program Files\TestApp\LibA) everything should work. Just restart the application and you are good to go.