Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 2nd March 2007, 12:30   #1
alx5962
Junior Member
 
Join Date: Dec 2006
Location: Lille, FRANCE
Posts: 18
Post My MySQL registry checker

As I didn't found a script on the nsis page to detect MySQL in the registry, I just wrote mine and decided to share it.
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"

code:

!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


alx5962 is offline   Reply With Quote
Old 2nd March 2007, 16:32   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
It'd be better whenever you want to share NSIS code to post it at wiki. This makes it easier for others to find it.
A quick look on the code; if you really want to preserve the values of $0, $1, $2, $R0, you should turn upside down when you Pop, see here , also probably you do not need StrCpy ${_RESULT} "" and StrCpy ${_RESULT2} "", while declared variables $path_result and $version_result are already empty

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 5th March 2007, 06:33   #3
alx5962
Junior Member
 
Join Date: Dec 2006
Location: Lille, FRANCE
Posts: 18
thank you for the tip
alx5962 is offline   Reply With Quote
Old 6th March 2007, 10:18   #4
fishweasel
Junior Member
 
Join Date: Nov 2006
Posts: 19
I had a similar requirement where i needed to detect MSDE /MSSQL and run the uninstaller path.
I used registry.nsh plugin to locate the path ,
then using that path, locate and run a substring :
(extracted code)
code:

!include "registry.nsh"

Function UninstallMSDE

### Get dynamic registry path by searching for MSDE (full name) and store path as $1
### Using $1 search for uninstall path - store as $R3
### Execute $R3 (msde uninstall path)

${registry::Open} "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" "/K=0 /V=0 /S=1 /B=1 /NS='Microsoft SQL Server Desktop Engine'" $0
StrCmp $0 0 0 loop
MessageBox MB_OK "Error getting MSDE registry entry use Add/Remove programs" IDOK close

loop:
${registry::Find} "$0" $1 $2 $3 $4

${registry::Open} "HKLM\$1" "/K=0 /V=1 /S=0 /B=1 /NS='UninstallString'" $R6
StrCmp $R6 0 0 loop2
MessageBox MB_OK "Error getting MSDE Uninstall registry entry use Add/Remove programs" IDOK close

loop2:
${registry::Find} "$R6" $R1 $R2 $R3 $R4

ExecWait $R3
close:
${registry::Close} "$0"
${registry::Unload}

FunctionEnd



It can probably be cleaned up a little - i really only modified the example scripts included in the plugin and cut it.

Unless RW and co see any major problems with the code i shall add it to WiKi later this week.
fishweasel is offline   Reply With Quote
Old 6th March 2007, 11:12   #5
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
My opinion is this; contribution should be our duty, this is the way NSIS grows up and spreads all over.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump