waplugin.nsi 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. ; waplugin.nsi
  2. ;
  3. ; This script will generate an installer that installs a Winamp 2 plug-in.
  4. ;
  5. ; This installer will automatically alert the user that installation was
  6. ; successful, and ask them whether or not they would like to make the
  7. ; plug-in the default and run Winamp.
  8. ;--------------------------------
  9. ; Uncomment the next line to enable auto Winamp download
  10. ; !define WINAMP_AUTOINSTALL
  11. ; The name of the installer
  12. Name "TinyVis Plug-in"
  13. ; The file to write
  14. OutFile "waplugin.exe"
  15. ; The default installation directory
  16. InstallDir $PROGRAMFILES\Winamp
  17. ; detect winamp path from uninstall string if available
  18. InstallDirRegKey HKLM \
  19. "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
  20. "UninstallString"
  21. ; The text to prompt the user to enter a directory
  22. DirText "Please select your Winamp path below (you will be able to proceed when Winamp is detected):"
  23. # currently doesn't work - DirShow hide
  24. ; automatically close the installer when done.
  25. AutoCloseWindow true
  26. ; hide the "show details" box
  27. ShowInstDetails nevershow
  28. ; Request application privileges for Windows Vista
  29. RequestExecutionLevel admin
  30. ;--------------------------------
  31. ;Pages
  32. Page directory
  33. Page instfiles
  34. ;--------------------------------
  35. ; The stuff to install
  36. Section ""
  37. !ifdef WINAMP_AUTOINSTALL
  38. Call MakeSureIGotWinamp
  39. !endif
  40. Call QueryWinampVisPath
  41. SetOutPath $1
  42. ; File to extract
  43. #File "C:\program files\winamp\plugins\vis_nsfs.dll"
  44. File /oname=vis_nsfs.dll "${NSISDIR}\Plugins\x86-ansi\TypeLib.dll" # dummy plug-in
  45. ; prompt user, and if they select no, go to NoWinamp
  46. MessageBox MB_YESNO|MB_ICONQUESTION \
  47. "The plug-in was installed. Would you like to run Winamp now with TinyVis as the default plug-in?" \
  48. IDNO NoWinamp
  49. WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_name" "vis_nsfs.dll"
  50. WriteINIStr "$INSTDIR\Winamp.ini" "Winamp" "visplugin_num" "0"
  51. Exec '"$INSTDIR\Winamp.exe"'
  52. NoWinamp:
  53. SectionEnd
  54. ;--------------------------------
  55. Function .onVerifyInstDir
  56. !ifndef WINAMP_AUTOINSTALL
  57. ;Check for Winamp installation
  58. IfFileExists $INSTDIR\Winamp.exe Good
  59. Abort
  60. Good:
  61. !endif ; WINAMP_AUTOINSTALL
  62. FunctionEnd
  63. Function QueryWinampVisPath ; sets $1 with vis path
  64. StrCpy $1 $INSTDIR\Plugins
  65. ; use DSPDir instead of VISDir to get DSP plugins directory
  66. ReadINIStr $9 $INSTDIR\winamp.ini Winamp VisDir
  67. StrCmp $9 "" End
  68. IfFileExists $9 0 End
  69. StrCpy $1 $9 ; update dir
  70. End:
  71. FunctionEnd
  72. !ifdef WINAMP_AUTOINSTALL
  73. Function GetWinampInstPath
  74. Push $0
  75. Push $1
  76. Push $2
  77. ReadRegStr $0 HKLM \
  78. "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
  79. "UninstallString"
  80. StrCmp $0 "" fin
  81. StrCpy $1 $0 1 0 ; get firstchar
  82. StrCmp $1 '"' "" getparent
  83. ; if first char is ", let's remove "'s first.
  84. StrCpy $0 $0 "" 1
  85. StrCpy $1 0
  86. rqloop:
  87. StrCpy $2 $0 1 $1
  88. StrCmp $2 '"' rqdone
  89. StrCmp $2 "" rqdone
  90. IntOp $1 $1 + 1
  91. Goto rqloop
  92. rqdone:
  93. StrCpy $0 $0 $1
  94. getparent:
  95. ; the uninstall string goes to an EXE, let's get the directory.
  96. StrCpy $1 -1
  97. gploop:
  98. StrCpy $2 $0 1 $1
  99. StrCmp $2 "" gpexit
  100. StrCmp $2 "\" gpexit
  101. IntOp $1 $1 - 1
  102. Goto gploop
  103. gpexit:
  104. StrCpy $0 $0 $1
  105. StrCmp $0 "" fin
  106. IfFileExists $0\winamp.exe fin
  107. StrCpy $0 ""
  108. fin:
  109. Pop $2
  110. Pop $1
  111. Exch $0
  112. FunctionEnd
  113. Function MakeSureIGotWinamp
  114. Call GetWinampInstPath
  115. Pop $0
  116. StrCmp $0 "" getwinamp
  117. Return
  118. getwinamp:
  119. Call ConnectInternet ;Make an internet connection (if no connection available)
  120. StrCpy $2 "$TEMP\Winamp Installer.exe"
  121. NSISdl::download http://download.nullsoft.com/winamp/client/winamp281_lite.exe $2
  122. Pop $0
  123. StrCmp $0 success success
  124. SetDetailsView show
  125. DetailPrint "download failed: $0"
  126. Abort
  127. success:
  128. ExecWait '"$2" /S'
  129. Delete $2
  130. Call GetWinampInstPath
  131. Pop $0
  132. StrCmp $0 "" skip
  133. StrCpy $INSTDIR $0
  134. skip:
  135. FunctionEnd
  136. Function ConnectInternet
  137. Push $R0
  138. ClearErrors
  139. Dialer::AttemptConnect
  140. IfErrors noie3
  141. Pop $R0
  142. StrCmp $R0 "online" connected
  143. MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet."
  144. Quit
  145. noie3:
  146. ; IE3 not installed
  147. MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now."
  148. connected:
  149. Pop $R0
  150. FunctionEnd
  151. !endif ; WINAMP_AUTOINSTALL