I'm new to NSIS coding so feel free to make a better code 😉
To use it :
Var $path_result
Var $version_result
!insertmacro CheckMySqlReg $path_result $version_result
DetailPrint "MySQL : located in $path_result with version $version_result"
!macro CheckMySqlReg _RESULT _RESULT2
Push $0
Push $1
Push $2
Push $R0
StrCpy $0 0
StrCpy ${_RESULT} ""
StrCpy ${_RESULT2} ""
loopSqlReg:
ClearErrors
EnumRegKey $1 HKLM "Software\MYSQL AB" $0
StrCmp $1 "" doneSqlReg
IntOp $0 $0 + 1
StrCpy $2 $1 12
StrCmp $2 "MySQL Server" foundSqlReg 0
Goto loopSqlReg
foundSqlReg:
ReadRegStr $R0 HKLM "Software\MYSQL AB\$1" "Location"
IfFileExists "$R0\bin\mysql.exe" 0 doneSqlReg
StrCpy ${_RESULT} "$R0"
ReadRegStr $R0 HKLM "Software\MYSQL AB\$1" "Version"
StrCpy ${_RESULT2} "$R0"
doneSqlReg:
Pop $0
Pop $1
Pop $2
Pop $R0
!macroend