tags:

views:

272

answers:

2

Hi,

1)Which is the best way to detect whether vs2005 runtimes are installed in a system using NSIS installer?

2)If runtimes are not detected which is the best way to add run time libraries-

     a)running an embedded vcredist or 
     b)copying dlls to the installation folder

Thanks

+2  A: 
;-------------------------------
; Test if Visual Studio Redistributables 2005+ SP1 installed
; Returns -1 if there is no VC redistributables intstalled
Function CheckVCRedist
   Push $R0
   ClearErrors
   ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7299052b-02a4-4627-81f2-1818da5d550d}" "Version"

   ; if VS 2005+ redist SP1 not installed, install it
   IfErrors 0 VSRedistInstalled
   StrCpy $R0 "-1"

VSRedistInstalled:
   Exch $R0
FunctionEnd

Of course you need to run the embedded installer, not copying files yourself. Confirm registry key "7299052b-02a4-4627-81f2-1818da5d550d" against your version of VC runtime.

FractalizeR
Thanks.It worked +1
NightCoder
You are welcome ;)
FractalizeR
And if the CRT is shipped as part of the OS with no uninstall entry?
Anders
I didn't test that, but anyway nothing bad will happen. Installer will detect, that they are already installed and will skip installation.
FractalizeR
+1  A: 

A while ago, I created some sample code that checks the assembly cache, it's probably better than just checking for a uninstall entry

Anders