tags:

views:

55

answers:

2

I'm implementing an installer in Java, that is supposed to download and install an application for non-privileged users in Windows (from XP and up). The application is written in C++, and depend on the usual VC runtime-libraries (msvcm90.dll and friends). In order to save bandwidth, I want to avoid downloading the VC redistributables if they already are available for the user. I do however have a problem finding a reliable method to detect if an assembly is installed.

If the assembly is missing, I will deploy it as described here:

http://msdn.microsoft.com/en-us/library/ms235291%28VS.80%29.aspx

So the question is simply how to detect if a (any) assembly is installed on the machine. It's no requirement that this can be done from Java. I can easily write a small probe in C++ and link it statically for the task.

jgaa

A: 

Seems a fairly complicated trick really as depending on the setup these may already be located in several possible places. Perhaps your best bet would be testing for the existence of these DLL's using the WinAPI LoadLibrary - this should find any DLL that is shared and appropriate to the build automatically.

Even better LoadLibrary a DLL that requires them as Ben suggests.

Elemental
Instead of calling `LoadLibrary` on the CRT DLLs (which will just get you the dreaded "R6034: An application has made an attempt to load the C runtime library incorrectly. Contact the application developer." message), call `LoadLibrary` on one of your own DLLs that requires them. That'll tell you if all the system manifests are properly installed.
Ben Voigt
Ben - Excellent suggestion, edited into answer
Elemental
+2  A: 

If you are willing to write a small test program, then rather than writing one that looks for your dependencies, write one that has the same dependencies as your application. Try to run it. If it runs, the dependencies are in place. If it fails, the probable reason is that the dependencies are missing.

OldFart
This is the same way that GNU autotools work, and is the most foolproof way of doing it, as well as being the simplest to implement. The same procedure can then be used to test your installation if you do need to download the dlls.
KeithB
This was my first thought too, and it works. I get the exit-code 0xc0000135 when I launch the probe and the assembly is missing. I am however surprised that there is no simple API for checking the presence of an assembly.
jgaa