]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/init.nsh
Win installer: 2 bugfixes
[features.git] / development / Win32 / packaging / installer / include / init.nsh
1 /*
2 init.nsh
3
4 Initialization functions
5 */
6
7 #--------------------------------
8 # User initialization
9
10 Var ComponentPath
11 Var LyXLangName
12
13 # COMPONENT can be LaTeX, ImageMagick and Ghostscript
14 !macro EXTERNAL_INIT COMPONENT
15
16   # APP_REGKEY_SETUP = "Software\${APP_NAME}${APP_SERIES_KEY}\Setup"
17   # where ${APP_NAME}${APP_SERIES_KEY} is something like LyX22
18   ReadRegStr $ComponentPath SHELL_CONTEXT "${APP_REGKEY_SETUP}" "${COMPONENT} Path"
19   
20   # BIN_LATEX etc are defined in settings.nsh
21   ${If} ${FileExists} "$ComponentPath\${BIN_${COMPONENT}}"
22     # set variables like PathLaTeX
23     StrCpy $Path${COMPONENT} $ComponentPath
24   ${EndIf}
25
26 !macroend
27
28 Function InitUser
29
30   # Get directories of components from registry
31   
32   !insertmacro EXTERNAL_INIT LaTeX
33   
34   # Get LyX language
35   
36   ReadRegStr $LyXLangName SHELL_CONTEXT "${APP_REGKEY_SETUP}" "LyX Language"
37   
38   ${If} $LyXLangName != ""
39     StrCpy $LangName $LyXLangName
40   ${EndIf}
41   
42 FunctionEnd
43
44 #--------------------------------
45 # visible installer sections
46
47 Section "!${APP_NAME}" SecCore
48  SectionIn RO
49  !if ${SETUPTYPE} == BUNDLE
50   # if no TeX was found MiKTeX will be installed which requires space
51   !if $PathLaTeX == ""
52    AddSize 1020000 # size in KB
53   !endif
54  !endif
55 SectionEnd
56
57 Section "$(SecFileAssocTitle)" SecFileAssoc
58  StrCpy $CreateFileAssociations "true" 
59 SectionEnd
60
61 Section "$(SecDesktopTitle)" SecDesktop
62  StrCpy $CreateDesktopIcon "true"
63 SectionEnd
64
65 !if ${SETUPTYPE} == BUNDLE
66  Section "$(SecInstJabRefTitle)" SecInstJabRef
67   AddSize ${SIZE_JABREF}
68   StrCpy $InstallJabRef "true"
69  SectionEnd
70 !endif
71
72 # Expand the list of dictionaries by default as this was requested by several
73 # users. For the thesaurus this is was not requested because this section
74 # is by default empty.
75 SectionGroup /e "Dictionaries" SecDictionaries
76
77 Section /o "Afrikaans" SecDAfrikaans
78  StrCpy $DictCodes "af_ZA,$DictCodes"
79  AddSize 1440
80 SectionEnd
81
82 Section /o "Arabic" SecDArabic
83  StrCpy $DictCodes "ar_DZ,$DictCodes"
84  AddSize 2500
85 SectionEnd
86
87 Section /o "Armenian" SecDArmenian
88  StrCpy $DictCodes "hy_AM,$DictCodes"
89  AddSize 2000
90 SectionEnd
91
92 Section /o "Bahasa Indonesia" SecDIndonesian
93  StrCpy $DictCodes "id_ID,$DictCodes"
94  AddSize 217
95 SectionEnd
96
97 Section /o "Bahasa Melayu" SecDMalayan
98  StrCpy $DictCodes "ms_MY,$DictCodes"
99  AddSize 227
100 SectionEnd
101
102 Section /o "Belarusian" SecDBelarusian 
103  StrCpy $DictCodes "be_BY,$DictCodes"
104  AddSize 1730
105 SectionEnd
106
107 Section /o "Brezhoneg" SecDBreton 
108  StrCpy $DictCodes "br_FR,$DictCodes"
109  AddSize 5510
110 SectionEnd
111
112 Section /o "Bulgarian" SecDBulgarian
113  StrCpy $DictCodes "bg_BG,$DictCodes"
114  AddSize 985
115 SectionEnd
116
117 Section /o "Català" SecDCatalanian
118  StrCpy $DictCodes "ca_ES,$DictCodes"
119  AddSize 1210
120 SectionEnd
121
122 Section /o "Ce\9atina" SecDCzech
123  StrCpy $DictCodes "cs_CZ,$DictCodes"
124  AddSize 2190
125 SectionEnd
126
127 Section /o "Coptic" SecDCoptic
128  StrCpy $DictCodes "cop_EG,$DictCodes"
129  AddSize 151
130 SectionEnd
131
132 Section /o "Cymraeg" SecDWelsh 
133  StrCpy $DictCodes "cy_GB,$DictCodes"
134  AddSize 1540
135 SectionEnd
136
137 Section /o "Dansk" SecDDanish
138  StrCpy $DictCodes "da_DK,$DictCodes"
139  AddSize 2470
140 SectionEnd
141
142 Section /o "German (A)" SecDGermanAT
143  StrCpy $DictCodes "de_AT,$DictCodes"
144  AddSize 3620
145 SectionEnd
146
147 Section /o "German (CH)" SecDGermanCH
148  StrCpy $DictCodes "de_CH,$DictCodes"
149  AddSize 3620
150 SectionEnd
151
152 Section "German (D)" SecDGermanD
153  # already installed by default
154  SectionIn RO
155  #StrCpy $DictCodes "de_DE,$DictCodes"
156  AddSize 3620
157 SectionEnd
158
159 Section /o "Greek" SecDGreek
160  StrCpy $DictCodes "el_GR,$DictCodes"
161  AddSize 6550
162 SectionEnd
163
164 Section /o "Eesti" SecDEstonian
165  StrCpy $DictCodes "et_EE,$DictCodes"
166  AddSize 4400
167 SectionEnd
168
169 Section /o "English (AU)" SecDEnglishAU
170  StrCpy $DictCodes "en_AU,$DictCodes"
171  AddSize 651
172 SectionEnd
173
174 Section /o "English (CA)" SecDEnglishCA
175  StrCpy $DictCodes "en_CA,$DictCodes"
176  AddSize 531
177 SectionEnd
178
179 Section "English (GB)" SecDEnglishGB
180  # already installed by default
181  SectionIn RO
182  #StrCpy $DictCodes "en_GB,$DictCodes"
183  AddSize 760
184 SectionEnd
185
186 Section /o "English (NZ)" SecDEnglishNZ
187  StrCpy $DictCodes "en_NZ,$DictCodes"
188  AddSize 551
189 SectionEnd
190
191 Section "English (US)" SecDEnglishUS
192  # already installed by default
193  SectionIn RO
194  #StrCpy $DictCodes "en_US,$DictCodes"
195  AddSize 547
196 SectionEnd
197
198 Section "Español (ES)" SecDSpanishES
199  # already installed by default
200  SectionIn RO
201  #StrCpy $DictCodes "es_ES,$DictCodes"
202  AddSize 974
203 SectionEnd
204
205 Section "Español (MX)" SecDSpanishMX
206  # already installed by default
207  SectionIn RO
208  #StrCpy $DictCodes "es_MX,$DictCodes"
209  AddSize 924
210 SectionEnd
211
212 Section /o "Esperanto" SecDEsperanto
213  StrCpy $DictCodes "eo_EO,$DictCodes"
214  AddSize 389
215 SectionEnd
216
217 Section /o "Euskara" SecDBasque
218  StrCpy $DictCodes "eu_ES,$DictCodes"
219  AddSize 4850
220 SectionEnd
221
222 Section /o "Farsi" SecDFarsi
223  StrCpy $DictCodes "fa_IR,$DictCodes"
224  AddSize 6710
225 SectionEnd
226
227 Section "Français" SecDFrench
228  # already installed by default
229  SectionIn RO
230  #StrCpy $DictCodes "fr_FR,$DictCodes"
231  AddSize 1200
232 SectionEnd
233
234 Section /o "Français (Canada)" SecDFrenchCanada
235  StrCpy $DictCodes "fr_CA,$DictCodes"
236  AddSize 1390
237 SectionEnd
238
239 Section /o "Gaeilge" SecDGaelic
240  StrCpy $DictCodes "ga_IR,$DictCodes"
241  AddSize 1090
242 SectionEnd
243
244 Section /o "Gàidhlig" SecDScottish
245  StrCpy $DictCodes "gd_GB,$DictCodes"
246  AddSize 4161
247 SectionEnd
248
249 Section /o "Galego" SecDGalician
250  StrCpy $DictCodes "gl_ES,$DictCodes"
251  AddSize 3911
252 SectionEnd
253
254 Section /o "Hebrew" SecDHebrew
255  StrCpy $DictCodes "he_IL,$DictCodes"
256  AddSize 3120
257 SectionEnd
258
259 Section /o "Hrvatski" SecDCroatian
260  StrCpy $DictCodes "hr_HR,$DictCodes"
261  AddSize 2240
262 SectionEnd
263
264 Section /o "Magyar" SecDHungarian
265  StrCpy $DictCodes "hu_HU,$DictCodes"
266  AddSize 3380
267 SectionEnd
268
269 Section /o "Hindi" SecDHindi
270  StrCpy $DictCodes "hi_IN,$DictCodes"
271  AddSize 1900
272 SectionEnd
273
274 Section /o "Interlingua" SecDInterlingua
275  StrCpy $DictCodes "ia_IA,$DictCodes"
276  AddSize 613
277 SectionEnd
278
279 Section /o "Íslenska" SecDIcelandic
280  StrCpy $DictCodes "is_IS,$DictCodes"
281  AddSize 2320
282 SectionEnd
283
284 Section /o "Italiano" SecDItalian
285  StrCpy $DictCodes "it_IT,$DictCodes"
286  AddSize 1380
287 SectionEnd
288
289 Section /o "Kazakh" SecDKazakh
290  StrCpy $DictCodes "kk_KZ,$DictCodes"
291  AddSize 2120
292 SectionEnd
293
294 Section /o "Korean" SecDKorean
295  StrCpy $DictCodes "ko_KR,$DictCodes"
296  AddSize 16540
297 SectionEnd
298
299 Section /o "Latina" SecDLatin
300  StrCpy $DictCodes "la_LA,$DictCodes"
301  AddSize 2040
302 SectionEnd
303
304 Section /o "Lietuviu" SecDLithuanian
305  StrCpy $DictCodes "lt_LT,$DictCodes"
306  AddSize 1320
307 SectionEnd
308
309 Section /o "Latvie\9au" SecDLatvian
310  StrCpy $DictCodes "lv_LV,$DictCodes"
311  AddSize 2243
312 SectionEnd
313
314 Section /o "Marathi" SecDMarathi
315  StrCpy $DictCodes "mr_IN,$DictCodes"
316  AddSize 5290
317 SectionEnd
318
319 Section /o "Nederlands" SecDDutch
320  StrCpy $DictCodes "nl_NL,$DictCodes"
321  AddSize 1820
322 SectionEnd
323
324 Section /o "Norsk (Bokmål)" SecDNorwegianNB
325  StrCpy $DictCodes "nb_NO,$DictCodes"
326  AddSize 5291
327 SectionEnd
328
329 Section /o "Norsk (Nynorsk)" SecDNorwegianNN
330  StrCpy $DictCodes "nn_NO,$DictCodes"
331  AddSize 3292
332 SectionEnd
333
334 Section /o "Occitan" SecDOccitan
335  StrCpy $DictCodes "oc_FR,$DictCodes"
336  AddSize 31710
337 SectionEnd
338
339 Section /o "Polski" SecDPolish
340  StrCpy $DictCodes "pl_PL,$DictCodes"
341  AddSize 4540
342 SectionEnd
343
344 Section /o "Português (BR)" SecDPortugueseBR
345  StrCpy $DictCodes "pt_BR,$DictCodes"
346  AddSize 5280
347 SectionEnd
348
349 Section /o "Português (PT)" SecDPortuguesePT
350  StrCpy $DictCodes "pt_PT,$DictCodes"
351  AddSize 1490
352 SectionEnd
353
354 Section /o "Româna" SecDRomanian
355  StrCpy $DictCodes "ro_RO,$DictCodes"
356  AddSize 2255
357 SectionEnd
358
359 Section /o "Russian" SecDRussian
360  StrCpy $DictCodes "ru_RU,$DictCodes"
361  AddSize 1920
362 SectionEnd
363
364 Section /o "Serb\9acina (Dolno)" SecDSorbianD
365  StrCpy $DictCodes "dsb_DE,$DictCodes"
366  AddSize 1035
367 SectionEnd
368
369 Section /o "Serb\9acina (Horno)" SecDSorbianH
370  StrCpy $DictCodes "hsb_DE,$DictCodes"
371  AddSize 740
372 SectionEnd
373
374 Section /o "Shqipe" SecDAlbanian
375  StrCpy $DictCodes "sq_AL,$DictCodes"
376  AddSize 2400
377 SectionEnd
378
379 Section /o "Sloven\9acina" SecDSlovenian
380  StrCpy $DictCodes "sl_SI,$DictCodes"
381  AddSize 2910
382 SectionEnd
383
384 Section /o "Slovenský" SecDSlovakian
385  StrCpy $DictCodes "sk_SK,$DictCodes"
386  AddSize 3310
387 SectionEnd
388
389 Section /o "Srpski (Cirilica)" SecDSerbianC
390  StrCpy $DictCodes "sr_RS,$DictCodes"
391  AddSize 4401
392 SectionEnd
393
394 Section /o "Srpski (Latinica)" SecDSerbianL
395  StrCpy $DictCodes "sr_RS-Latin,$DictCodes"
396  AddSize 2843
397 SectionEnd
398
399 Section /o "Svenska" SecDSwedish
400  StrCpy $DictCodes "sv_SE,$DictCodes"
401  AddSize 2028
402 SectionEnd
403
404 Section /o "Tamil" SecDTamil
405  StrCpy $DictCodes "ta_IN,$DictCodes"
406  AddSize 5911
407 SectionEnd
408
409 Section /o "Telugu" SecDTelugu
410  StrCpy $DictCodes "te_IN,$DictCodes"
411  AddSize 3400
412 SectionEnd
413  
414 Section /o "Thai" SecDThai
415  StrCpy $DictCodes "th_TH,$DictCodes"
416  AddSize 351
417 SectionEnd
418
419 Section /o "Türkmençe" SecDTurkmen
420  StrCpy $DictCodes "tk_TM,$DictCodes"
421  AddSize 950
422 SectionEnd
423
424 Section /o "Türkçe" SecDTurkish
425  StrCpy $DictCodes "tr_TR,$DictCodes"
426  AddSize 8870
427 SectionEnd
428
429 Section /o "Ukrainian" SecDUkrainian
430  StrCpy $DictCodes "uk_UA,$DictCodes"
431  AddSize 3077
432 SectionEnd
433
434 Section /o "Urdu" SecDUrdu
435  StrCpy $DictCodes "ur_PK,$DictCodes"
436  AddSize 1401
437 SectionEnd
438
439 Section /o "Vietnamese" SecDVietnamese
440  StrCpy $DictCodes "vi_VN,$DictCodes"
441  AddSize 40
442 SectionEnd
443
444 SectionGroupEnd
445
446
447 SectionGroup "Thesaurus" SecThesaurus
448
449 Section /o "Bulgarian" SecTBulgarian
450  StrCpy $ThesCodes "bg_BG,$ThesCodes"
451  AddSize 3020
452 SectionEnd
453
454 Section /o "Català" SecTCatalan
455  StrCpy $ThesCodes "ca_ES,$ThesCodes"
456  AddSize 731
457 SectionEnd
458
459 Section /o "Ce\9atina" SecTCzech
460  StrCpy $ThesCodes "cs_CZ,$ThesCodes"
461  AddSize 635
462 SectionEnd
463
464 Section /o "Dansk" SecTDanish
465  StrCpy $ThesCodes "da_DK,$ThesCodes"
466  AddSize 2360
467 SectionEnd
468
469 Section /o "Deutsch (D/A)" SecTGermanDA
470  StrCpy $ThesCodes "de_DE,$ThesCodes"
471  AddSize 14600
472 SectionEnd
473
474 Section /o "Deutsch (CH)" SecTGermanCH
475  StrCpy $ThesCodes "de_CH,$ThesCodes"
476  AddSize 14600
477 SectionEnd
478
479 Section /o "English (GB)" SecTEnglishGB
480  StrCpy $ThesCodes "en_GB,$ThesCodes"
481  AddSize 14300
482 SectionEnd
483
484 Section /o "English (US/AU)" SecTEnglishUSAU
485  StrCpy $ThesCodes "en_US,$ThesCodes"
486  AddSize 22095
487 SectionEnd
488
489 Section /o "Español" SecTSpanish
490  StrCpy $ThesCodes "es_ES,$ThesCodes"
491  AddSize 2860
492 SectionEnd
493
494 Section /o "Français" SecTFrench
495  StrCpy $ThesCodes "fr_FR,$ThesCodes"
496  AddSize 5060
497 SectionEnd
498
499 Section /o "Gaeilge" SecTGaelic
500  StrCpy $ThesCodes "ga_IR,$ThesCodes"
501  AddSize 30600
502 SectionEnd
503
504 Section /o "Galego" SecTGalician
505  StrCpy $ThesCodes "gl_ES,$ThesCodes"
506  AddSize 510
507 SectionEnd
508
509 Section /o "Greek" SecTGreek
510  StrCpy $ThesCodes "el_GR,$ThesCodes"
511  AddSize 903
512 SectionEnd
513
514 Section /o "Íslenska" SecTIcelandic
515  StrCpy $ThesCodes "is_IS,$ThesCodes"
516  AddSize 63
517 SectionEnd
518
519 Section /o "Italiano" SecTItalian
520  StrCpy $ThesCodes "it_IT,$ThesCodes"
521  AddSize 2520
522 SectionEnd
523
524 Section /o "Magyar" SecTHungarian
525  StrCpy $ThesCodes "hu_HU,$ThesCodes"
526  AddSize 632
527 SectionEnd
528
529 Section /o "Norsk (Bokmål)" SecTNorwegianNB
530  StrCpy $ThesCodes "nb_NO,$ThesCodes"
531  AddSize 2595
532 SectionEnd
533
534 Section /o "Norsk (Nynorsk)" SecTNorwegianNN
535  StrCpy $ThesCodes "nn_NO,$ThesCodes"
536  AddSize 2
537 SectionEnd
538
539 Section /o "Polski" SecTPolish
540  StrCpy $ThesCodes "pl_PL,$ThesCodes"
541  AddSize 5580
542 SectionEnd
543
544 Section /o "Português" SecTPortuguese
545  StrCpy $ThesCodes "pt_PT,$ThesCodes"
546  AddSize 860
547 SectionEnd
548
549 Section /o "Româna" SecTRomanian
550  StrCpy $ThesCodes "ro_RO,$ThesCodes"
551  AddSize 3650
552 SectionEnd
553
554 Section /o "Russian" SecTRussian
555  StrCpy $ThesCodes "ru_RU,$ThesCodes"
556  AddSize 2080
557 SectionEnd
558
559 Section /o "Sloven\9acina" SecTSlovenian
560  StrCpy $ThesCodes "sl_SI,$ThesCodes"
561  AddSize 1110
562 SectionEnd
563
564 Section /o "Slovenský" SecTSlovakian
565  StrCpy $ThesCodes "sk_SK,$ThesCodes"
566  AddSize 930
567 SectionEnd
568
569 Section /o "Svenska" SecTSwedish
570  StrCpy $ThesCodes "sv_SE,$ThesCodes"
571  AddSize 720
572 SectionEnd
573
574 Section /o "Ukrainian" SecTUkrainian
575  StrCpy $ThesCodes "uk_UA,$ThesCodes"
576  AddSize 1309
577 SectionEnd
578
579 SectionGroupEnd
580
581 # Section descriptions
582 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
583 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
584 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
585 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
586 !if ${SETUPTYPE} == BUNDLE
587  !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
588 !endif
589 !insertmacro MUI_DESCRIPTION_TEXT ${SecDictionaries} "$(SecDictionariesDescription)"
590 !insertmacro MUI_DESCRIPTION_TEXT ${SecThesaurus} "$(SecThesaurusDescription)"
591 !insertmacro MUI_FUNCTION_DESCRIPTION_END
592
593
594 # .onInit must be here after the section definition because we have to set
595 # the selection states of the dictionary sections
596 Function .onInit
597
598   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
599   ${if} $R0 == "5.0" # 2000
600   ${orif} $R0 == "5.1" # XP
601   ${orif} $R0 == "5.2" # 2003
602     MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} ${APP_VERSION} requires Windows Vista or newer." /SD IDOK
603     Quit
604   ${endif}
605   
606   # check that the installer is not currently running
607   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${BundleExeFile}.Instance") i .r1 ?e'
608   Pop $R0
609   ${if} $R0 != "0"
610    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)" /SD IDOK
611    Abort
612   ${endif}
613   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${ExeFile}.Instance") i .r1 ?e'
614   Pop $R0
615   ${if} $R0 != "0"
616    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)" /SD IDOK
617    Abort
618   ${endif}
619   
620   # FIXME: check that LyX is not currently running
621   #System::Call 'kernel32::CreateMutexA(i 0, i 0, t "LyX.exe.Instance") i .r1 ?e'
622   #Pop $R0
623   #MessageBox MB_OK "$R0"
624   #${if} $R0 != "0"
625   # MessageBox MB_OK|MB_ICONSTOP "$(LyXRunning)" 
626   # Abort
627   #${endif}
628   
629   # read the user and computer name
630   ReadRegStr $ComputerName HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
631   System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"
632   StrCpy $UserName $0
633   
634   !insertmacro MULTIUSER_INIT
635   
636   # check if this LyX version is already installed
637   ${if} $MultiUser.Privileges == "Admin"
638   ${orif} $MultiUser.Privileges == "Power"
639    ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayIcon"
640   ${else}
641    ReadRegStr $0 HKCU "${APP_UNINST_KEY}" "DisplayIcon"
642    # handle also the case that LyX is already installed in HKLM
643    ${if} $0 == ""
644     ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayIcon"
645    ${endif}
646   ${endif}
647   ${if} $0 != ""
648    # check if the uninstaller was acidentally deleted
649    # if so don't bother the user if he realy wants to install a new LyX over an existing one
650    # because he won't have a chance to deny this
651    StrCpy $4 $0 -10 # remove '\bin\lyx,0'
652    # (for FileCheck the variables $0 and $1 cannot be used)
653    !insertmacro FileCheck $5 "Uninstall-LyX.exe" "$4" # macro from LyXUtils.nsh
654    ${if} $5 == "False"
655     Goto ForceInstallation
656    ${endif}
657    # installing over an existing installation of the same LyX release is not necessary
658    # if the users does this he most probably has a problem with LyX that can better be solved
659    # by reinstalling LyX
660    # for beta and other test releases over-installing can even cause errors
661    MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONEXCLAMATION "$(AlreadyInstalled)" /SD IDNO IDYES ForceInstallation 
662    Abort
663    ForceInstallation:
664   ${endif}
665   
666   # check if there is an existing LyX installation of the same LyX series
667   # we usually don't release more than 10 versions so with 20 we are safe to check if a newer version is installed
668   IntOp $4 ${APP_VERSION_REVISION} + 20
669   ${for} $5 0 $4
670    ${if} $MultiUser.Privileges == "Admin"
671    ${orif} $MultiUser.Privileges == "Power"
672     ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$5" "DisplayVersion"
673     # also check for an emergency release
674     ${if} $0 == ""
675      ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$51" "DisplayVersion"
676     ${endif}
677    ${else}
678     ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$5" "DisplayVersion"
679     # also check for an emergency release
680     ${if} $0 == ""
681      ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$51" "DisplayVersion"
682     ${endif}
683    ${endif}
684    ${if} $0 != ""
685     StrCpy $R5 $0 # store the read version number
686     StrCpy $OldVersionNumber "${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$5"
687     # we don't stop here because we want the latest installed version
688    ${endif} 
689   ${next}
690   
691   ${if} $OldVersionNumber > ${APP_SERIES_KEY}
692    # store the version number and reformat it temporarily for the error message
693    StrCpy $R0 $OldVersionNumber
694    StrCpy $OldVersionNumber $R5
695    MessageBox MB_OK|MB_ICONSTOP "$(NewerInstalled)" /SD IDOK
696    StrCpy $OldVersionNumber $R0
697    Abort
698   ${endif}
699
700   # this can be reset to "true" in section SecDesktop
701   StrCpy $CreateDesktopIcon "false"
702   StrCpy $CreateFileAssociations "false"
703  
704   ${IfNot} ${Silent}
705     # Show banner while installer is intializating 
706     Banner::show /NOUNLOAD "Checking system"
707   ${EndIf}
708  
709   Call SearchExternal
710   
711   !if ${SETUPTYPE} == BUNDLE
712    # don't let the installer sections appear when the programs are already installed
713    ${if} $PathBibTeXEditor != ""
714     SectionSetText 3 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
715    ${endif}
716   !endif
717   
718   # select sections of already installed spell-checker dictionaries, make them read-only
719   # and set the necessary size to 0 bytes
720   StrCpy $String $FoundDict
721   StrCpy $Search "af_ZA"
722   Call StrPoint # function from LyXUtils.nsh
723   ${if} $Pointer != "-1"
724    IntOp $0 ${SF_SELECTED} | ${SF_RO}
725    SectionSetFlags ${SecDAfrikaans} $0
726    SectionSetSize ${SecDAfrikaans} 0
727   ${endif}
728   StrCpy $Search "ar_DZ"
729   Call StrPoint
730   ${if} $Pointer != "-1"
731    IntOp $0 ${SF_SELECTED} | ${SF_RO}
732    SectionSetFlags ${SecDArabic} $0
733    SectionSetSize ${SecDArabic} 0
734   ${endif}
735   StrCpy $Search "hy_AM"
736   Call StrPoint
737   ${if} $Pointer != "-1"
738    IntOp $0 ${SF_SELECTED} | ${SF_RO}
739    SectionSetFlags ${SecDArmenian} $0
740    SectionSetSize ${SecDArmenian} 0
741   ${endif}
742   StrCpy $Search "id_ID"
743   Call StrPoint
744   ${if} $Pointer != "-1"
745    IntOp $0 ${SF_SELECTED} | ${SF_RO}
746    SectionSetFlags ${SecDIndonesian} $0
747    SectionSetSize ${SecDIndonesian} 0
748   ${endif}
749   StrCpy $Search "ms_MY"
750   Call StrPoint
751   ${if} $Pointer != "-1"
752    IntOp $0 ${SF_SELECTED} | ${SF_RO}
753    SectionSetFlags ${SecDMalayan} $0
754    SectionSetSize ${SecDMalayan} 0
755   ${endif}
756   StrCpy $Search "be_BY"
757   Call StrPoint
758   ${if} $Pointer != "-1"
759    IntOp $0 ${SF_SELECTED} | ${SF_RO}
760    SectionSetFlags ${SecDBelarusian} $0
761    SectionSetSize ${SecDBelarusian} 0
762   ${endif}
763   StrCpy $Search "br_FR"
764   Call StrPoint
765   ${if} $Pointer != "-1"
766    IntOp $0 ${SF_SELECTED} | ${SF_RO}
767    SectionSetFlags ${SecDBreton} $0
768    SectionSetSize ${SecDBreton} 0
769   ${endif}
770   StrCpy $Search "bg_BG"
771   Call StrPoint
772   ${if} $Pointer != "-1"
773    IntOp $0 ${SF_SELECTED} | ${SF_RO}
774    SectionSetFlags ${SecDBulgarian} $0
775    SectionSetSize ${SecDBulgarian} 0
776   ${endif}
777   StrCpy $Search "ca_ES"
778   Call StrPoint
779   ${if} $Pointer != "-1"
780    IntOp $0 ${SF_SELECTED} | ${SF_RO}
781    SectionSetFlags ${SecDCatalanian} $0
782    SectionSetSize ${SecDCatalanian} 0
783   ${endif}
784   StrCpy $Search "cs_CZ"
785   Call StrPoint
786   ${if} $Pointer != "-1"
787    IntOp $0 ${SF_SELECTED} | ${SF_RO}
788    SectionSetFlags ${SecDCzech} $0
789    SectionSetSize ${SecDCzech} 0
790   ${endif}
791  
792   StrCpy $Search "cop_EG"
793   Call StrPoint
794   ${if} $Pointer != "-1"
795    IntOp $0 ${SF_SELECTED} | ${SF_RO}
796    SectionSetFlags ${SecDCoptic} $0
797    SectionSetSize ${SecDCoptic} 0
798   ${endif}
799   StrCpy $Search "cy_GB"
800   Call StrPoint
801   ${if} $Pointer != "-1"
802    IntOp $0 ${SF_SELECTED} | ${SF_RO}
803    SectionSetFlags ${SecDWelsh} $0
804    SectionSetSize ${SecDWelsh} 0
805   ${endif}
806   StrCpy $Search "da_DK"
807   Call StrPoint
808   ${if} $Pointer != "-1"
809    IntOp $0 ${SF_SELECTED} | ${SF_RO}
810    SectionSetFlags ${SecDDanish} $0
811    SectionSetSize ${SecDDanish} 0
812   ${endif}
813   StrCpy $Search "de_AT"
814   Call StrPoint
815   ${if} $Pointer != "-1"
816    IntOp $0 ${SF_SELECTED} | ${SF_RO}
817    SectionSetFlags ${SecDGermanAT} $0
818    SectionSetSize ${SecDGermanAT} 0
819   ${endif}
820   StrCpy $Search "de_CH"
821   Call StrPoint
822   ${if} $Pointer != "-1"
823    IntOp $0 ${SF_SELECTED} | ${SF_RO}
824    SectionSetFlags ${SecDGermanCH} $0
825    SectionSetSize ${SecDGermanCH} 0
826   ${endif}
827   StrCpy $Search "de_DE"
828   Call StrPoint
829   ${if} $Pointer != "-1"
830    IntOp $0 ${SF_SELECTED} | ${SF_RO}
831    SectionSetFlags ${SecDGermanD} $0
832    SectionSetSize ${SecDGermanD} 0
833   ${endif}
834   StrCpy $Search "el_GR"
835   Call StrPoint
836   ${if} $Pointer != "-1"
837    IntOp $0 ${SF_SELECTED} | ${SF_RO}
838    SectionSetFlags ${SecDGreek} $0
839    SectionSetSize ${SecDGreek} 0
840   ${endif}
841   StrCpy $Search "et_EE"
842   Call StrPoint
843   ${if} $Pointer != "-1"
844    IntOp $0 ${SF_SELECTED} | ${SF_RO}
845    SectionSetFlags ${SecDEstonian} $0
846    SectionSetSize ${SecDEstonian} 0
847   ${endif}
848   StrCpy $Search "en_AU"
849   Call StrPoint
850   ${if} $Pointer != "-1"
851    IntOp $0 ${SF_SELECTED} | ${SF_RO}
852    SectionSetFlags ${SecDEnglishAU} $0
853    SectionSetSize ${SecDEnglishAU} 0
854   ${endif}
855   StrCpy $Search "en_CA"
856   Call StrPoint
857   ${if} $Pointer != "-1"
858    IntOp $0 ${SF_SELECTED} | ${SF_RO}
859    SectionSetFlags ${SecDEnglishCA} $0
860    SectionSetSize ${SecDEnglishCA} 0
861   ${endif}
862   StrCpy $Search "en_GB"
863   Call StrPoint
864   ${if} $Pointer != "-1"
865    IntOp $0 ${SF_SELECTED} | ${SF_RO}
866    SectionSetFlags ${SecDEnglishGB} $0
867    SectionSetSize ${SecDEnglishGB} 0
868   ${endif}
869   StrCpy $Search "en_NZ"
870   Call StrPoint
871   ${if} $Pointer != "-1"
872    IntOp $0 ${SF_SELECTED} | ${SF_RO}
873    SectionSetFlags ${SecDEnglishNZ} $0
874    SectionSetSize ${SecDEnglishNZ} 0
875   ${endif}
876   StrCpy $Search "en_US"
877   Call StrPoint
878   ${if} $Pointer != "-1"
879    IntOp $0 ${SF_SELECTED} | ${SF_RO}
880    SectionSetFlags ${SecDEnglishUS} $0
881    SectionSetSize ${SecDEnglishUS} 0
882   ${endif}
883   StrCpy $Search "es_ES"
884   Call StrPoint
885   ${if} $Pointer != "-1"
886    IntOp $0 ${SF_SELECTED} | ${SF_RO}
887    SectionSetFlags ${SecDSpanishES} $0
888    SectionSetSize ${SecDSpanishES} 0
889   ${endif}
890   StrCpy $Search "es_MX"
891   Call StrPoint
892   ${if} $Pointer != "-1"
893    IntOp $0 ${SF_SELECTED} | ${SF_RO}
894    SectionSetFlags ${SecDSpanishMX} $0
895    SectionSetSize ${SecDSpanishMX} 0
896   ${endif}
897   StrCpy $Search "eo_EO"
898   Call StrPoint
899   ${if} $Pointer != "-1"
900    IntOp $0 ${SF_SELECTED} | ${SF_RO}
901    SectionSetFlags ${SecDEsperanto} $0
902    SectionSetSize ${SecDEsperanto} 0
903   ${endif}
904   StrCpy $Search "eu_ES"
905   Call StrPoint
906   ${if} $Pointer != "-1"
907    IntOp $0 ${SF_SELECTED} | ${SF_RO}
908    SectionSetFlags ${SecDBasque} $0
909    SectionSetSize ${SecDBasque} 0
910   ${endif}
911   StrCpy $Search "fa_IR"
912   Call StrPoint
913   ${if} $Pointer != "-1"
914    IntOp $0 ${SF_SELECTED} | ${SF_RO}
915    SectionSetFlags ${SecDFarsi} $0
916    SectionSetSize ${SecDFarsi} 0
917   ${endif}
918   StrCpy $Search "fr_CA"
919   Call StrPoint
920   ${if} $Pointer != "-1"
921    IntOp $0 ${SF_SELECTED} | ${SF_RO}
922    SectionSetFlags ${SecDFrenchCanada} $0
923    SectionSetSize ${SecDFrenchCanada} 0
924   ${endif}
925   StrCpy $Search "fr_FR"
926   Call StrPoint
927   ${if} $Pointer != "-1"
928    IntOp $0 ${SF_SELECTED} | ${SF_RO}
929    SectionSetFlags ${SecDFrench} $0
930    SectionSetSize ${SecDFrench} 0
931   ${endif}
932   StrCpy $Search "ga_IR"
933   Call StrPoint
934   ${if} $Pointer != "-1"
935    IntOp $0 ${SF_SELECTED} | ${SF_RO}
936    SectionSetFlags ${SecDGaelic} $0
937    SectionSetSize ${SecDGaelic} 0
938   ${endif}
939   StrCpy $Search "gd_GB"
940   Call StrPoint
941   ${if} $Pointer != "-1"
942    IntOp $0 ${SF_SELECTED} | ${SF_RO}
943    SectionSetFlags ${SecDScottish} $0
944    SectionSetSize ${SecDScottish} 0
945   ${endif}
946   StrCpy $Search "gl_ES"
947   Call StrPoint
948   ${if} $Pointer != "-1"
949    IntOp $0 ${SF_SELECTED} | ${SF_RO}
950    SectionSetFlags ${SecDGalician} $0
951    SectionSetSize ${SecDGalician} 0
952   ${endif}
953   StrCpy $Search "he_IL"
954   Call StrPoint
955   ${if} $Pointer != "-1"
956    IntOp $0 ${SF_SELECTED} | ${SF_RO}
957    SectionSetFlags ${SecDHebrew} $0
958    SectionSetSize ${SecDHebrew} 0
959   ${endif}
960   StrCpy $Search "hi_IN"
961   Call StrPoint
962   ${if} $Pointer != "-1"
963    IntOp $0 ${SF_SELECTED} | ${SF_RO}
964    SectionSetFlags ${SecDHindi} $0
965    SectionSetSize ${SecDHindi} 0
966   ${endif}
967   StrCpy $Search "hr_HR"
968   Call StrPoint
969   ${if} $Pointer != "-1"
970    IntOp $0 ${SF_SELECTED} | ${SF_RO}
971    SectionSetFlags ${SecDCroatian} $0
972    SectionSetSize ${SecDCroatian} 0
973   ${endif}
974   StrCpy $Search "hu_HU"
975   Call StrPoint
976   ${if} $Pointer != "-1"
977    IntOp $0 ${SF_SELECTED} | ${SF_RO}
978    SectionSetFlags ${SecDHungarian} $0
979    SectionSetSize ${SecDHungarian} 0
980   ${endif}
981   StrCpy $Search "ia_IA"
982   Call StrPoint
983   ${if} $Pointer != "-1"
984    IntOp $0 ${SF_SELECTED} | ${SF_RO}
985    SectionSetFlags ${SecDInterlingua} $0
986    SectionSetSize ${SecDInterlingua} 0
987   ${endif}
988   StrCpy $Search "is_IS"
989   Call StrPoint
990   ${if} $Pointer != "-1"
991    IntOp $0 ${SF_SELECTED} | ${SF_RO}
992    SectionSetFlags ${SecDIcelandic} $0
993    SectionSetSize ${SecDIcelandic} 0
994   ${endif}
995   StrCpy $Search "it_IT"
996   Call StrPoint
997   ${if} $Pointer != "-1"
998    IntOp $0 ${SF_SELECTED} | ${SF_RO}
999    SectionSetFlags ${SecDItalian} $0
1000    SectionSetSize ${SecDItalian} 0
1001   ${endif}
1002   StrCpy $Search "kk_KZ"
1003   Call StrPoint
1004   ${if} $Pointer != "-1"
1005    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1006    SectionSetFlags ${SecDKazakh} $0
1007    SectionSetSize ${SecDKazakh} 0
1008   ${endif}
1009   StrCpy $Search "ko_KR"
1010   Call StrPoint
1011   ${if} $Pointer != "-1"
1012    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1013    SectionSetFlags ${SecDKorean} $0
1014    SectionSetSize ${SecDKorean} 0
1015   ${endif}
1016   StrCpy $Search "la_LA"
1017   Call StrPoint
1018   ${if} $Pointer != "-1"
1019    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1020    SectionSetFlags ${SecDLatin} $0
1021    SectionSetSize ${SecDLatin} 0
1022   ${endif}
1023   StrCpy $Search "lt_LT"
1024   Call StrPoint
1025   ${if} $Pointer != "-1"
1026    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1027    SectionSetFlags ${SecDLithuanian} $0
1028    SectionSetSize ${SecDLithuanian} 0
1029   ${endif}
1030   StrCpy $Search "lv_LV"
1031   Call StrPoint
1032   ${if} $Pointer != "-1"
1033    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1034    SectionSetFlags ${SecDLatvian} $0
1035    SectionSetSize ${SecDLatvian} 0
1036   ${endif}
1037   StrCpy $Search "mr_IN"
1038   Call StrPoint
1039   ${if} $Pointer != "-1"
1040    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1041    SectionSetFlags ${SecDMarathi} $0
1042    SectionSetSize ${SecDMarathi} 0
1043   ${endif}
1044   StrCpy $Search "nl_NL"
1045   Call StrPoint
1046   ${if} $Pointer != "-1"
1047    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1048    SectionSetFlags ${SecDDutch} $0
1049    SectionSetSize ${SecDDutch} 0
1050   ${endif}
1051   StrCpy $Search "nb_NO"
1052   Call StrPoint
1053   ${if} $Pointer != "-1"
1054    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1055    SectionSetFlags ${SecDNorwegianNB} $0
1056    SectionSetSize ${SecDNorwegianNB} 0
1057   ${endif}
1058   StrCpy $Search "nn_NO"
1059   Call StrPoint
1060   ${if} $Pointer != "-1"
1061    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1062    SectionSetFlags ${SecDNorwegianNN} $0
1063    SectionSetSize ${SecDNorwegianNN} 0
1064   ${endif}
1065   StrCpy $Search "oc_FR"
1066   Call StrPoint
1067   ${if} $Pointer != "-1"
1068    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1069    SectionSetFlags ${SecDOccitan} $0
1070    SectionSetSize ${SecDOccitan} 0
1071   ${endif}
1072   StrCpy $Search "pl_PL"
1073   Call StrPoint
1074   ${if} $Pointer != "-1"
1075    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1076    SectionSetFlags ${SecDPolish} $0
1077    SectionSetSize ${SecDPolish} 0
1078   ${endif}
1079   StrCpy $Search "pt_BR"
1080   Call StrPoint
1081   ${if} $Pointer != "-1"
1082    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1083    SectionSetFlags ${SecDPortugueseBR} $0
1084    SectionSetSize ${SecDPortugueseBR} 0
1085   ${endif}
1086   StrCpy $Search "pt_PT"
1087   Call StrPoint
1088   ${if} $Pointer != "-1"
1089    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1090    SectionSetFlags ${SecDPortuguesePT} $0
1091    SectionSetSize ${SecDPortuguesePT} 0
1092   ${endif}
1093   StrCpy $Search "ro_RO"
1094   Call StrPoint
1095   ${if} $Pointer != "-1"
1096    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1097    SectionSetFlags ${SecDRomanian} $0
1098    SectionSetSize ${SecDRomanian} 0
1099   ${endif}
1100   StrCpy $Search "ru_RU"
1101   Call StrPoint
1102   ${if} $Pointer != "-1"
1103    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1104    SectionSetFlags ${SecDRussian} $0
1105    SectionSetSize ${SecDRussian} 0
1106   ${endif}
1107   StrCpy $Search "dsb_DE"
1108   Call StrPoint
1109   ${if} $Pointer != "-1"
1110    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1111    SectionSetFlags ${SecDSorbianD} $0
1112    SectionSetSize ${SecDSorbianD} 0
1113   ${endif}
1114   StrCpy $Search "hsb_DE"
1115   Call StrPoint
1116   ${if} $Pointer != "-1"
1117    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1118    SectionSetFlags ${SecDSorbianH} $0
1119    SectionSetSize ${SecDSorbianH} 0
1120   ${endif}
1121   StrCpy $Search "sq_AL"
1122   Call StrPoint
1123   ${if} $Pointer != "-1"
1124    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1125    SectionSetFlags ${SecDAlbanian} $0
1126    SectionSetSize ${SecDAlbanian} 0
1127   ${endif}
1128   StrCpy $Search "sl_SI"
1129   Call StrPoint
1130   ${if} $Pointer != "-1"
1131    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1132    SectionSetFlags ${SecDSlovenian} $0
1133    SectionSetSize ${SecDSlovenian} 0
1134   ${endif}
1135   StrCpy $Search "sk_SK"
1136   Call StrPoint
1137   ${if} $Pointer != "-1"
1138    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1139    SectionSetFlags ${SecDSlovakian} $0
1140    SectionSetSize ${SecDSlovakian} 0
1141   ${endif}
1142   StrCpy $Search "sr_RS"
1143   Call StrPoint
1144   ${if} $Pointer != "-1"
1145    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1146    SectionSetFlags ${SecDSerbianC} $0
1147    SectionSetSize ${SecDSerbianC} 0
1148   ${endif}
1149   StrCpy $Search "sr_RS-Latin"
1150   Call StrPoint
1151   ${if} $Pointer != "-1"
1152    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1153    SectionSetFlags ${SecDSerbianL} $0
1154    SectionSetSize ${SecDSerbianL} 0
1155   ${endif}
1156   StrCpy $Search "sv_SE"
1157   Call StrPoint
1158   ${if} $Pointer != "-1"
1159    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1160    SectionSetFlags ${SecDSwedish} $0
1161    SectionSetSize ${SecDSwedish} 0
1162   ${endif}
1163   StrCpy $Search "ta_IN"
1164   Call StrPoint
1165   ${if} $Pointer != "-1"
1166    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1167    SectionSetFlags ${SecDTamil} $0
1168    SectionSetSize ${SecDTamil} 0
1169   ${endif}
1170   StrCpy $Search "te_IN"
1171   Call StrPoint
1172   ${if} $Pointer != "-1"
1173    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1174    SectionSetFlags ${SecDTelugu} $0
1175    SectionSetSize ${SecDTelugu} 0
1176   ${endif}
1177   StrCpy $Search "th_TH"
1178   Call StrPoint
1179   ${if} $Pointer != "-1"
1180    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1181    SectionSetFlags ${SecDThai} $0
1182    SectionSetSize ${SecDThai} 0
1183   ${endif}
1184   StrCpy $Search "tk_TM"
1185   Call StrPoint
1186   ${if} $Pointer != "-1"
1187    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1188    SectionSetFlags ${SecDTurkmen} $0
1189    SectionSetSize ${SecDTurkmen} 0
1190   ${endif}
1191   StrCpy $Search "tr_TR"
1192   Call StrPoint
1193   ${if} $Pointer != "-1"
1194    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1195    SectionSetFlags ${SecDTurkish} $0
1196    SectionSetSize ${SecDTurkish} 0
1197   ${endif}
1198   StrCpy $Search "uk_UA"
1199   Call StrPoint
1200   ${if} $Pointer != "-1"
1201    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1202    SectionSetFlags ${SecDUkrainian} $0
1203    SectionSetSize ${SecDUkrainian} 0
1204   ${endif}
1205   StrCpy $Search "ur_PK"
1206   Call StrPoint
1207   ${if} $Pointer != "-1"
1208    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1209    SectionSetFlags ${SecDUrdu} $0
1210    SectionSetSize ${SecDUrdu} 0
1211   ${endif}
1212   StrCpy $Search "vi_VN"
1213   Call StrPoint
1214   ${if} $Pointer != "-1"
1215    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1216    SectionSetFlags ${SecDVietnamese} $0
1217    SectionSetSize ${SecDVietnamese} 0
1218   ${endif}
1219   
1220   # select sections of already installed thesaurus dictionaries, make them read-only
1221   # and set the necessary size to 0 bytes
1222   StrCpy $String $FoundThes
1223   StrCpy $Search "bg_BG"
1224   Call StrPoint # function from LyXUtils.nsh
1225   ${if} $Pointer != "-1"
1226    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1227    SectionSetFlags ${SecTBulgarian} $0
1228    SectionSetSize ${SecTBulgarian} 0
1229   ${endif}
1230   StrCpy $Search "ca_ES"
1231   Call StrPoint
1232   ${if} $Pointer != "-1"
1233    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1234    SectionSetFlags ${SecTCatalan} $0
1235    SectionSetSize ${SecTCatalan} 0
1236   ${endif}
1237   StrCpy $Search "cs_CZ"
1238   Call StrPoint
1239   ${if} $Pointer != "-1"
1240    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1241    SectionSetFlags ${SecTCzech} $0
1242    SectionSetSize ${SecTCzech} 0
1243   ${endif}
1244   StrCpy $Search "da_DK"
1245   Call StrPoint
1246   ${if} $Pointer != "-1"
1247    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1248    SectionSetFlags ${SecTDanish} $0
1249    SectionSetSize ${SecTDanish} 0
1250   ${endif}
1251   StrCpy $Search "de_DE"
1252   Call StrPoint
1253   ${if} $Pointer != "-1"
1254    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1255    SectionSetFlags ${SecTGermanDA} $0
1256    SectionSetSize ${SecTGermanDA} 0
1257   ${endif} 
1258   StrCpy $Search "de_CH"
1259   Call StrPoint
1260   ${if} $Pointer != "-1"
1261    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1262    SectionSetFlags ${SecTGermanCH} $0
1263    SectionSetSize ${SecTGermanCH} 0
1264   ${endif}
1265   StrCpy $Search "en_GB"
1266   Call StrPoint
1267   ${if} $Pointer != "-1"
1268    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1269    SectionSetFlags ${SecTEnglishGB} $0
1270    SectionSetSize ${SecTEnglishGB} 0
1271   ${endif} 
1272   StrCpy $Search "en_US"
1273   Call StrPoint
1274   ${if} $Pointer != "-1"
1275    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1276    SectionSetFlags ${SecTEnglishUSAU} $0
1277    SectionSetSize ${SecTEnglishUSAU} 0
1278   ${endif}
1279   StrCpy $Search "es_ES"
1280   Call StrPoint
1281   ${if} $Pointer != "-1"
1282    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1283    SectionSetFlags ${SecTSpanish} $0
1284    SectionSetSize ${SecTSpanish} 0
1285   ${endif}
1286   StrCpy $Search "fr_FR"
1287   Call StrPoint
1288   ${if} $Pointer != "-1"
1289    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1290    SectionSetFlags ${SecTFrench} $0
1291    SectionSetSize ${SecTFrench} 0
1292   ${endif}
1293   StrCpy $Search "ga_IR"
1294   Call StrPoint
1295   ${if} $Pointer != "-1"
1296    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1297    SectionSetFlags ${SecTGaelic} $0
1298    SectionSetSize ${SecTGaelic} 0
1299   ${endif}
1300   StrCpy $Search "gl_ES"
1301   Call StrPoint
1302   ${if} $Pointer != "-1"
1303    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1304    SectionSetFlags ${SecTGalician} $0
1305    SectionSetSize ${SecTGalician} 0
1306   ${endif}
1307   StrCpy $Search "el_GR"
1308   Call StrPoint
1309   ${if} $Pointer != "-1"
1310    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1311    SectionSetFlags ${SecTGreek} $0
1312    SectionSetSize ${SecTGreek} 0
1313   ${endif}
1314   StrCpy $Search "is_IS"
1315   Call StrPoint
1316   ${if} $Pointer != "-1"
1317    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1318    SectionSetFlags ${SecTIcelandic} $0
1319    SectionSetSize ${SecTIcelandic} 0
1320   ${endif}
1321   StrCpy $Search "it_IT"
1322   Call StrPoint
1323   ${if} $Pointer != "-1"
1324    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1325    SectionSetFlags ${SecTItalian} $0
1326    SectionSetSize ${SecTItalian} 0
1327   ${endif}
1328   StrCpy $Search "hu_HU"
1329   Call StrPoint
1330   ${if} $Pointer != "-1"
1331    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1332    SectionSetFlags ${SecTHungarian} $0
1333    SectionSetSize ${SecTHungarian} 0
1334   ${endif}
1335   StrCpy $Search "nb_NO"
1336   Call StrPoint
1337   ${if} $Pointer != "-1"
1338    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1339    SectionSetFlags ${SecTNorwegianNB} $0
1340    SectionSetSize ${SecTNorwegianNB} 0
1341   ${endif}
1342   StrCpy $Search "nn_NO"
1343   Call StrPoint
1344   ${if} $Pointer != "-1"
1345    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1346    SectionSetFlags ${SecTNorwegianNN} $0
1347    SectionSetSize ${SecTNorwegianNN} 0
1348   ${endif}
1349   StrCpy $Search "pl_PL"
1350   Call StrPoint
1351   ${if} $Pointer != "-1"
1352    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1353    SectionSetFlags ${SecTPolish} $0
1354    SectionSetSize ${SecTPolish} 0
1355   ${endif}
1356   StrCpy $Search "pt_PT"
1357   Call StrPoint
1358   ${if} $Pointer != "-1"
1359    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1360    SectionSetFlags ${SecTPortuguese} $0
1361    SectionSetSize ${SecTPortuguese} 0
1362   ${endif}
1363   StrCpy $Search "ro_RO"
1364   Call StrPoint
1365   ${if} $Pointer != "-1"
1366    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1367    SectionSetFlags ${SecTRomanian} $0
1368    SectionSetSize ${SecTRomanian} 0
1369   ${endif}
1370   StrCpy $Search "ru_RU"
1371   Call StrPoint
1372   ${if} $Pointer != "-1"
1373    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1374    SectionSetFlags ${SecTRussian} $0
1375    SectionSetSize ${SecTRussian} 0
1376   ${endif}
1377   StrCpy $Search "sl_SI"
1378   Call StrPoint
1379   ${if} $Pointer != "-1"
1380    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1381    SectionSetFlags ${SecTSlovenian} $0
1382    SectionSetSize ${SecTSlovenian} 0
1383   ${endif}
1384   StrCpy $Search "sk_SK"
1385   Call StrPoint
1386   ${if} $Pointer != "-1"
1387    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1388    SectionSetFlags ${SecTSlovakian} $0
1389    SectionSetSize ${SecTSlovakian} 0
1390   ${endif}
1391   StrCpy $Search "sv_SE"
1392   Call StrPoint
1393   ${if} $Pointer != "-1"
1394    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1395    SectionSetFlags ${SecTSwedish} $0
1396    SectionSetSize ${SecTSwedish} 0
1397   ${endif}
1398   StrCpy $Search "uk_UA"
1399   Call StrPoint
1400   ${if} $Pointer != "-1"
1401    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1402    SectionSetFlags ${SecTUkrainian} $0
1403    SectionSetSize ${SecTUkrainian} 0
1404   ${endif}
1405   
1406   ${IfNot} ${Silent}
1407     Banner::destroy
1408   ${EndIf}
1409
1410 FunctionEnd
1411
1412 # this function is called at first after starting the uninstaller
1413 Function un.onInit
1414
1415   !insertmacro MULTIUSER_UNINIT
1416
1417   # Check that LyX is not currently running
1418   FindProcDLL::FindProc "lyx.exe"
1419   ${if} $R0 == "1"
1420    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)" /SD IDOK
1421    Abort
1422   ${endif}
1423
1424   # set registry root key
1425   ${if} $MultiUser.Privileges == "Admin"
1426   ${orif} $MultiUser.Privileges == "Power"
1427     SetShellVarContext all
1428   ${else}
1429    SetShellVarContext current
1430   ${endif}
1431
1432   # Ascertain whether the user has sufficient privileges to uninstall.
1433   # abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
1434   ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayVersion"
1435   ${if} $0 != ""
1436   ${andif} $MultiUser.Privileges != "Admin"
1437   ${andif} $MultiUser.Privileges != "Power"
1438    MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)" /SD IDOK
1439    Abort
1440   ${endif}
1441   # warning when LyX couldn't be found in the registry
1442   ${if} $0 == "" # check in HKCU
1443    ReadRegStr $0 HKCU "${APP_UNINST_KEY}" "DisplayVersion"
1444    ${if} $0 == ""
1445      MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)" /SD IDOK
1446    ${endif}
1447   ${endif}
1448   
1449   # Macro to investigate name of LyX's preferences folders to be able remove them
1450   !insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
1451
1452   # test if MiKTeX was installed together with LyX
1453   ReadRegStr $0 SHCTX "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
1454   ${if} $0 == "Yes${APP_SERIES_KEY}"
1455    SectionSetText 2 "MiKTeX" # names the corersponding uninstaller section
1456    StrCpy $LaTeXInstalled "MiKTeX"
1457   ${else}
1458    SectionSetText 2 "" # hides the corresponding uninstaller section
1459   ${endif}
1460   
1461   # test if JabRef was installed together with LyX
1462   ReadRegStr $0 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef" "OnlyWithLyX"
1463   ${if} $0 == "Yes${APP_SERIES_KEY}"
1464    SectionSetText 3 "JabRef" # names the corersponding uninstaller section
1465    StrCpy $JabRefInstalled "Yes"
1466   ${else}
1467    SectionSetText 3 "" # hides the corresponding uninstaller section
1468   ${endif}
1469
1470   # question message if the user really wants to uninstall LyX
1471   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" /SD IDYES IDYES +2 # continue if yes
1472   Abort
1473
1474 FunctionEnd
1475