OSDN Git Service

MacGui: Remove Target Size as a rate control option as it doesn't really work correct...
[handbrake-jp/handbrake-jp-git.git] / win / C# / Installer / Installer.nsi
1 /*  Resources.Designer.cs $\r
2 \r
3            This file is part of the HandBrake source code.\r
4            Homepage: <http://handbrake.fr/>.\r
5            It may be used under the terms of the GNU General Public License. */\r
6 \r
7 ; Script generated by the HM NIS Edit Script Wizard.\r
8 \r
9 ; HM NIS Edit Wizard helper defines\r
10 !define PRODUCT_NAME "HandBrake"\r
11 !define PRODUCT_VERSION "0.9.5"\r
12 !define PRODUCT_VERSION_NUMBER "0.9.5"\r
13 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Handbrake.exe"\r
14 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"\r
15 !define PRODUCT_UNINST_ROOT_KEY "HKLM"\r
16 \r
17 ;Required .NET framework\r
18 !define MIN_FRA_MAJOR "3"\r
19 !define MIN_FRA_MINOR "5"\r
20 !define MIN_FRA_BUILD "*"\r
21 \r
22 SetCompressor lzma\r
23 \r
24 ; MUI 1.67 compatible ------\r
25 !include "MUI.nsh"\r
26 \r
27 ; MUI Settings\r
28 !define MUI_ABORTWARNING\r
29 !define MUI_ICON "handbrakepineapple.ico"\r
30 !define MUI_UNICON "handbrakepineapple.ico"\r
31 \r
32 ; Welcome page\r
33 !insertmacro MUI_PAGE_WELCOME\r
34 ; License page\r
35 !insertmacro MUI_PAGE_LICENSE "doc\COPYING"\r
36 ; Directory page\r
37 !insertmacro MUI_PAGE_DIRECTORY\r
38 ; Instfiles page\r
39 !insertmacro MUI_PAGE_INSTFILES\r
40 ; Finish page\r
41 !define MUI_FINISHPAGE_RUN "$INSTDIR\Handbrake.exe"\r
42 !insertmacro MUI_PAGE_FINISH\r
43 \r
44 ; Uninstaller pages\r
45 !insertmacro MUI_UNPAGE_INSTFILES\r
46 \r
47 ; Language files\r
48 !insertmacro MUI_LANGUAGE "English"\r
49 \r
50 ; MUI end ------\r
51 \r
52 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"\r
53 OutFile "HandBrake-${PRODUCT_VERSION_NUMBER}-Win_GUI.exe"\r
54 \r
55 !include WordFunc.nsh\r
56 !insertmacro VersionCompare\r
57 !include LogicLib.nsh\r
58 \r
59 InstallDir "$PROGRAMFILES\Handbrake"\r
60 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""\r
61 ShowInstDetails show\r
62 ShowUnInstDetails show\r
63 \r
64 Var InstallDotNET\r
65 \r
66 Function .onInit\r
67 \r
68   ; Begin Only allow one version\r
69   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'\r
70   Pop $R0\r
71 \r
72   StrCmp $R0 0 +3\r
73   MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."\r
74   Abort\r
75 \r
76   ;Remove previous version\r
77   ReadRegStr $R0 HKLM \\r
78   "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}\" \\r
79   "UninstallString"\r
80   StrCmp $R0 "" done\r
81 \r
82   MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \\r
83   "${PRODUCT_NAME} is already installed. $\n$\nClick `OK` to remove the \\r
84   previous version or `Cancel` to continue." \\r
85   IDOK uninst\r
86   goto done\r
87 \r
88  ;Run the uninstaller\r
89   uninst:\r
90    Exec $INSTDIR\uninst.exe\r
91   done:\r
92 FunctionEnd\r
93 \r
94 Section "Handbrake" SEC01\r
95   SetOutPath "$INSTDIR"\r
96   SetOverwrite ifnewer\r
97 \r
98   ; Begin Check .NET version\r
99   StrCpy $InstallDotNET "No"\r
100   Call CheckFramework\r
101      StrCmp $0 "1" +3\r
102         StrCpy $InstallDotNET "Yes"\r
103       MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} requires that the .NET Framework 3.5 SP1 is installed. The latest .NET Framework will be downloaded and installed automatically during installation of ${PRODUCT_NAME}."\r
104      Pop $0\r
105 \r
106   ; Get .NET if required\r
107   ${If} $InstallDotNET == "Yes"\r
108      SetDetailsView hide\r
109      inetc::get /caption "Downloading .NET Framework 3.5" /canceltext "Cancel" "http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=ab99342f-5d1a-413d-8319-81da479ab0d7&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f0%2f6%2f1%2f061f001c-8752-4600-a198-53214c69b51f%2fdotnetfx35setup.exe" "$INSTDIR\dotnetfx.exe" /end\r
110      Pop $1\r
111 \r
112      ${If} $1 != "OK"\r
113            Delete "$INSTDIR\dotnetfx.exe"\r
114            Abort "Installation cancelled, ${PRODUCT_NAME} requires the .NET 3.5 Framework"\r
115      ${EndIf}\r
116 \r
117      ExecWait "$INSTDIR\dotnetfx.exe"\r
118      Delete "$INSTDIR\dotnetfx.exe"\r
119 \r
120      SetDetailsView show\r
121   ${EndIf}\r
122   \r
123   ; Install Files\r
124   File "Handbrake.exe"\r
125   File "HandBrakeCLI.exe"\r
126   CreateDirectory "$SMPROGRAMS\Handbrake"\r
127   CreateShortCut "$SMPROGRAMS\Handbrake\Handbrake.lnk" "$INSTDIR\Handbrake.exe"\r
128   CreateShortCut "$DESKTOP\Handbrake.lnk" "$INSTDIR\Handbrake.exe"\r
129   File "Interop.QTOLibrary.dll"\r
130   File "Interop.QTOControlLib.dll"\r
131   File "AxInterop.QTOControlLib.dll"\r
132   File "Growl.Connector.dll"\r
133   File "Growl.CoreLibrary.dll"\r
134   File "Handbrake.exe.config"\r
135   File "HandBrake.ApplicationServices.dll"\r
136   File "HandBrake.Framework.dll"\r
137   File "Microsoft.WindowsAPICodePack.Shell.dll"\r
138   File "Microsoft.WindowsAPICodePack.dll"\r
139   File "HandBrakeInterop.dll"\r
140 \r
141   ;File "Caliburn.Castle.dll"\r
142   ;File "Caliburn.Core.dll"\r
143   ;File "Castle.Core.dll"\r
144   ;File "Castle.DynamicProxy2.dll"\r
145   ;File "Castle.MicroKernel.dll"\r
146   ;File "Castle.Windsor.dll"\r
147   ;File "Microsoft.Practices.ServiceLocation.dll"\r
148 \r
149   ; Copy the standard doc set into the doc folder\r
150   SetOutPath "$INSTDIR\doc"\r
151   SetOverwrite ifnewer\r
152   File "doc\AUTHORS"\r
153   File "doc\COPYING"\r
154   File "doc\CREDITS"\r
155   File "doc\NEWS"\r
156   File "doc\THANKS"\r
157   File "doc\TRANSLATIONS"\r
158 SectionEnd\r
159 \r
160 Section -AdditionalIcons\r
161   CreateShortCut "$SMPROGRAMS\Handbrake\Uninstall.lnk" "$INSTDIR\uninst.exe"\r
162 SectionEnd\r
163 \r
164 Section -Post\r
165   WriteUninstaller "$INSTDIR\uninst.exe"\r
166   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Handbrake.exe"\r
167   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"\r
168   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"\r
169   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Handbrake.exe"\r
170   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"\r
171 SectionEnd\r
172 \r
173 \r
174 Function un.onUninstSuccess\r
175   HideWindow\r
176   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."\r
177 FunctionEnd\r
178 \r
179 Function un.onInit\r
180   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2\r
181   Abort\r
182 FunctionEnd\r
183 \r
184 Section Uninstall\r
185   Delete "$INSTDIR\uninst.exe"\r
186   \r
187   Delete "$INSTDIR\Interop.QTOLibrary.dll"\r
188   Delete "$INSTDIR\Interop.QTOControlLib.dll"\r
189   Delete "$INSTDIR\AxInterop.QTOControlLib.dll"\r
190   Delete "$INSTDIR\HandBrakeCLI.exe"\r
191   Delete "$INSTDIR\handbrakepineapple.ico"\r
192   Delete "$INSTDIR\Handbrake.exe"\r
193   Delete "$INSTDIR\Handbrake.exe.config"\r
194   Delete "$INSTDIR\Growl.Connector.dll"\r
195   Delete "$INSTDIR\Growl.CoreLibrary.dll"\r
196   Delete "$INSTDIR\libgcc_s_sjlj-1.dll"\r
197   Delete "$INSTDIR\HandBrake.ApplicationServices.dll"\r
198   Delete "$INSTDIR\HandBrake.Framework.dll"\r
199   Delete "$INSTDIR\Microsoft.WindowsAPICodePack.Shell.dll"\r
200   Delete "$INSTDIR\Microsoft.WindowsAPICodePack.dll"\r
201   Delete "$INSTDIR\HandBrakeInterop.dll"\r
202 \r
203   Delete "$INSTDIR\Caliburn.Castle.dll"\r
204   Delete "$INSTDIR\Caliburn.Core.dll"\r
205   Delete "$INSTDIR\Castle.Core.dll"\r
206   Delete "$INSTDIR\Castle.DynamicProxy2.dll"\r
207   Delete "$INSTDIR\Castle.MicroKernel.dll"\r
208   Delete "$INSTDIR\Castle.Windsor.dll"\r
209   Delete "$INSTDIR\Microsoft.Practices.ServiceLocation.dll"\r
210 \r
211   Delete "$INSTDIR\doc\AUTHORS"\r
212   Delete "$INSTDIR\doc\COPYING"\r
213   Delete "$INSTDIR\doc\CREDITS"\r
214   Delete "$INSTDIR\doc\NEWS"\r
215   Delete "$INSTDIR\doc\THANKS"\r
216   Delete "$INSTDIR\doc\TRANSLATIONS"\r
217   RMDir  "$INSTDIR"\r
218   Delete "$SMPROGRAMS\Handbrake\Uninstall.lnk"\r
219   Delete "$DESKTOP\Handbrake.lnk"\r
220   Delete "$SMPROGRAMS\Handbrake\Handbrake.lnk"\r
221   RMDir  "$SMPROGRAMS\Handbrake"\r
222   RMDir  "$INSTDIR"\r
223 \r
224   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"\r
225   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"\r
226   SetAutoClose true\r
227 SectionEnd\r
228 \r
229 ;Check for .NET framework\r
230 Function CheckFrameWork\r
231 \r
232    ;Save the variables in case something else is using them\r
233   Push $0\r
234   Push $1\r
235   Push $2\r
236   Push $3\r
237   Push $4\r
238   Push $R1\r
239   Push $R2\r
240   Push $R3\r
241   Push $R4\r
242   Push $R5\r
243   Push $R6\r
244   Push $R7\r
245   Push $R8\r
246 \r
247   StrCpy $R5 "0"\r
248   StrCpy $R6 "0"\r
249   StrCpy $R7 "0"\r
250   StrCpy $R8 "0.0.0"\r
251   StrCpy $0 0\r
252 \r
253   loop:\r
254 \r
255   ;Get each sub key under "SOFTWARE\Microsoft\NET Framework Setup\NDP"\r
256   EnumRegKey $1 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP" $0\r
257   StrCmp $1 "" done ;jump to end if no more registry keys\r
258   IntOp $0 $0 + 1\r
259   StrCpy $2 $1 1 ;Cut off the first character\r
260   StrCpy $3 $1 "" 1 ;Remainder of string\r
261 \r
262   ;Loop if first character is not a 'v'\r
263   StrCmpS $2 "v" start_parse loop\r
264 \r
265   ;Parse the string\r
266   start_parse:\r
267   StrCpy $R1 ""\r
268   StrCpy $R2 ""\r
269   StrCpy $R3 ""\r
270   StrCpy $R4 $3\r
271 \r
272   StrCpy $4 1\r
273 \r
274   parse:\r
275   StrCmp $3 "" parse_done ;If string is empty, we are finished\r
276   StrCpy $2 $3 1 ;Cut off the first character\r
277   StrCpy $3 $3 "" 1 ;Remainder of string\r
278   StrCmp $2 "." is_dot not_dot ;Move to next part if it's a dot\r
279 \r
280   is_dot:\r
281   IntOp $4 $4 + 1 ; Move to the next section\r
282   goto parse ;Carry on parsing\r
283 \r
284   not_dot:\r
285   IntCmp $4 1 major_ver\r
286   IntCmp $4 2 minor_ver\r
287   IntCmp $4 3 build_ver\r
288   IntCmp $4 4 parse_done\r
289 \r
290   major_ver:\r
291   StrCpy $R1 $R1$2\r
292   goto parse ;Carry on parsing\r
293 \r
294   minor_ver:\r
295   StrCpy $R2 $R2$2\r
296   goto parse ;Carry on parsing\r
297 \r
298   build_ver:\r
299   StrCpy $R3 $R3$2\r
300   goto parse ;Carry on parsing\r
301 \r
302   parse_done:\r
303 \r
304   IntCmp $R1 $R5 this_major_same loop this_major_more\r
305   this_major_more:\r
306   StrCpy $R5 $R1\r
307   StrCpy $R6 $R2\r
308   StrCpy $R7 $R3\r
309   StrCpy $R8 $R4\r
310 \r
311   goto loop\r
312 \r
313   this_major_same:\r
314   IntCmp $R2 $R6 this_minor_same loop this_minor_more\r
315   this_minor_more:\r
316   StrCpy $R6 $R2\r
317   StrCpy $R7 R3\r
318   StrCpy $R8 $R4\r
319   goto loop\r
320 \r
321   this_minor_same:\r
322   IntCmp $R3 $R7 loop loop this_build_more\r
323   this_build_more:\r
324   StrCpy $R7 $R3\r
325   StrCpy $R8 $R4\r
326   goto loop\r
327 \r
328   done:\r
329 \r
330   ;Have we got the framework we need?\r
331   IntCmp $R5 ${MIN_FRA_MAJOR} max_major_same fail OK\r
332   max_major_same:\r
333   IntCmp $R6 ${MIN_FRA_MINOR} max_minor_same fail OK\r
334   max_minor_same:\r
335   IntCmp $R7 ${MIN_FRA_BUILD} OK fail OK\r
336 \r
337   ;Version on machine is greater than what we need\r
338   OK:\r
339   StrCpy $0 "1"\r
340   goto end\r
341 \r
342   fail:\r
343   StrCmp $R8 "0.0.0" end\r
344 \r
345 \r
346   end:\r
347 \r
348   ;Pop the variables we pushed earlier\r
349   Pop $R8\r
350   Pop $R7\r
351   Pop $R6\r
352   Pop $R5\r
353   Pop $R4\r
354   Pop $R3\r
355   Pop $R2\r
356   Pop $R1\r
357   Pop $4\r
358   Pop $3\r
359   Pop $2\r
360   Pop $1\r
361 FunctionEnd