Skip to content
⌘ NSIS Forum Archive

Detect and show all VC ++ versions installed in a RichEdit/Label control

3 posts

meoit#

Detect and show all VC ++ versions installed in a RichEdit/Label control

I am trying to do an installer that includes the VC ++ versions.
In it, there is a button to remove an existing or old VC ++ version.
And I want to check which versions of VC ++ are installed, then show it to RichEdit / Label.

I was told, to access the registry with a loop $ {FOR}:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{xxxxxx-uuuu-ddddd-zzzzzz-yyyyyyyyyyyy}

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{xxxxxx-uuuu-ddddd-zzzzzz-yyyyyyyyyyyy}

How can I query for string GUID(s) of VC ++ {xxxxxx-uuuu-ddddd-zzzzzz-yyyyyyyyyyyy} ?

Thanks.
stass#
OutFile "MSIFuncTest.exe"
!include "MUI2.nsh" 
!include "Sections.nsh"
!define MsiGetProductInfo '!insertmacro MsiGetProductInfo'
!define redists "{08D44BDE-2EB1-11E8-AF3D-001B2160B4E0}"   ;  corresponding GUID
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
RequestExecutionLevel admin
Var /GLOBAL err
!macro MSI_ERROR
${If} $err == "1602"
DetailPrint "Installation aborted"
${ElseIf} $err == "1638"
DetailPrint "Another version of VC ++ is already installed. Installation continues ..."
${ElseIf} $err == "0"
DetailPrint "VC ++ installed successfully"
${EndIf}
!macroend
Var MSI_PRODUCT
!macro MsiGetProductInfo PRODUCTCODE PROPERTY
 Push ${PRODUCTCODE}
 Push ${PROPERTY}
 Exch $0
 Exch
 Exch $1
 Push $2
 Push $3
 Push $4
 Push $5
 System::Alloc 2
 Pop $3
 System::Call 'msi::MsiGetProductInfo(t r1,t r0,n,i $3)i .r2'
 System::Call '*$3(&i2 .r5)'
 InTop $5 $5 + 1
 System::Call '*$3(&i2 r5)'
 System::Alloc $5
 Pop $4
 System::Call 'msi::MsiGetProductInfo(t r1,t r0,i $4,i $3)i .r2'
 System::Call '*$3(&i2 .r5)'
 System::Call '*$4(&t$5 .r0)'
 System::Free $3              
 System::Free $4
 Pop $5
 Pop $4
 Pop $3
 Pop $1
 Exch $0
 Pop $MSI_PRODUCT
!macroend
Section /o "vc++" vc
SetDetailsPrint textonly
DetailPrint "Installing MSVCRT Redists {08D44BDE-2EB1-11E8-AF3D-001B2160B4E0}..."
SetDetailsPrint listonly
SetShellVarContext all
SetOverwrite on
SetDetailsPrint none
SetOutPath "$TEMP"
File /r "redist"
SetDetailsPrint none
ExecWait 'msiexec /i "$TEMP\redist\redists.msi" /quiet' $err 
SetDetailsPrint textonly
!insertmacro MSI_ERROR
Sleep 1000
RmDir /r "$TEMP\redist"
SectionEnd
Function .onInit
${MsiGetProductInfo} "${redists}" "ProductName"
;MessageBox MB_OK "Code Error $2"
${If} $2 == 1605
MessageBox MB_OK "MSVCRT Redists Not installed !"
SectionSetFlags ${vc} ${SF_SELECTED}
${EndIf}
${If} $2 == 0
MessageBox MB_OK "MSVCRT Redists already installed"
ExecWait "MsiExec.exe /X{08D44BDE-2EB1-11E8-AF3D-001B2160B4E0}"
${EndIf}
FunctionEnd