Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Examples / waplugin.nsi @ 2021

Historique | Voir | Annoter | Télécharger (4,59 ko)

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