Statistiques
| Révision :

root / tmp / org.txm.setups / nsis-2.5 / Examples / waplugin.nsi @ 3116

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

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