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