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