]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/init.nsh
Win installer: fix 2 bugs and update libraries
[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 552
172 SectionEnd
173
174 Section /o "English (CA)" SecDEnglishCA
175  StrCpy $DictCodes "en_CA,$DictCodes"
176  AddSize 550
177 SectionEnd
178
179 Section "English (GB)" SecDEnglishGB
180  # already installed by default
181  SectionIn RO
182  #StrCpy $DictCodes "en_GB,$DictCodes"
183  AddSize 742
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 548
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 1568
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 "Tibetan" SecDTibetan
420  StrCpy $DictCodes "bo_CN,$DictCodes"
421  AddSize 7
422 SectionEnd
423
424 Section /o "Türkmençe" SecDTurkmen
425  StrCpy $DictCodes "tk_TM,$DictCodes"
426  AddSize 950
427 SectionEnd
428
429 Section /o "Türkçe" SecDTurkish
430  StrCpy $DictCodes "tr_TR,$DictCodes"
431  AddSize 8870
432 SectionEnd
433
434 Section /o "Ukrainian" SecDUkrainian
435  StrCpy $DictCodes "uk_UA,$DictCodes"
436  AddSize 5555
437 SectionEnd
438
439 Section /o "Urdu" SecDUrdu
440  StrCpy $DictCodes "ur_PK,$DictCodes"
441  AddSize 1401
442 SectionEnd
443
444 Section /o "Vietnamese" SecDVietnamese
445  StrCpy $DictCodes "vi_VN,$DictCodes"
446  AddSize 40
447 SectionEnd
448
449 SectionGroupEnd
450
451
452 SectionGroup "Thesaurus" SecThesaurus
453
454 Section /o "Bulgarian" SecTBulgarian
455  StrCpy $ThesCodes "bg_BG,$ThesCodes"
456  AddSize 3020
457 SectionEnd
458
459 Section /o "Català" SecTCatalan
460  StrCpy $ThesCodes "ca_ES,$ThesCodes"
461  AddSize 731
462 SectionEnd
463
464 Section /o "Ce\9atina" SecTCzech
465  StrCpy $ThesCodes "cs_CZ,$ThesCodes"
466  AddSize 635
467 SectionEnd
468
469 Section /o "Dansk" SecTDanish
470  StrCpy $ThesCodes "da_DK,$ThesCodes"
471  AddSize 2360
472 SectionEnd
473
474 Section /o "Deutsch (D/A)" SecTGermanDA
475  StrCpy $ThesCodes "de_DE,$ThesCodes"
476  AddSize 14600
477 SectionEnd
478
479 Section /o "Deutsch (CH)" SecTGermanCH
480  StrCpy $ThesCodes "de_CH,$ThesCodes"
481  AddSize 14600
482 SectionEnd
483
484 Section /o "English (AU)" SecTEnglishAU
485  StrCpy $ThesCodes "en_AU,$ThesCodes"
486  AddSize 21642
487 SectionEnd
488
489 Section /o "English (GB)" SecTEnglishGB
490  StrCpy $ThesCodes "en_GB,$ThesCodes"
491  AddSize 14300
492 SectionEnd
493
494 Section /o "English (US)" SecTEnglishUS
495  StrCpy $ThesCodes "en_US,$ThesCodes"
496  AddSize 22095
497 SectionEnd
498
499 Section /o "Español" SecTSpanish
500  StrCpy $ThesCodes "es_ES,$ThesCodes"
501  AddSize 2860
502 SectionEnd
503
504 Section /o "Français" SecTFrench
505  StrCpy $ThesCodes "fr_FR,$ThesCodes"
506  AddSize 5060
507 SectionEnd
508
509 Section /o "Gaeilge" SecTGaelic
510  StrCpy $ThesCodes "ga_IR,$ThesCodes"
511  AddSize 30600
512 SectionEnd
513
514 Section /o "Galego" SecTGalician
515  StrCpy $ThesCodes "gl_ES,$ThesCodes"
516  AddSize 510
517 SectionEnd
518
519 Section /o "Greek" SecTGreek
520  StrCpy $ThesCodes "el_GR,$ThesCodes"
521  AddSize 903
522 SectionEnd
523
524 Section /o "Íslenska" SecTIcelandic
525  StrCpy $ThesCodes "is_IS,$ThesCodes"
526  AddSize 63
527 SectionEnd
528
529 Section /o "Italiano" SecTItalian
530  StrCpy $ThesCodes "it_IT,$ThesCodes"
531  AddSize 2520
532 SectionEnd
533
534 Section /o "Magyar" SecTHungarian
535  StrCpy $ThesCodes "hu_HU,$ThesCodes"
536  AddSize 632
537 SectionEnd
538
539 Section /o "Norsk (Bokmål)" SecTNorwegianNB
540  StrCpy $ThesCodes "nb_NO,$ThesCodes"
541  AddSize 2595
542 SectionEnd
543
544 Section /o "Norsk (Nynorsk)" SecTNorwegianNN
545  StrCpy $ThesCodes "nn_NO,$ThesCodes"
546  AddSize 2
547 SectionEnd
548
549 Section /o "Polski" SecTPolish
550  StrCpy $ThesCodes "pl_PL,$ThesCodes"
551  AddSize 5580
552 SectionEnd
553
554 Section /o "Português" SecTPortuguese
555  StrCpy $ThesCodes "pt_PT,$ThesCodes"
556  AddSize 3950
557 SectionEnd
558
559 Section /o "Româna" SecTRomanian
560  StrCpy $ThesCodes "ro_RO,$ThesCodes"
561  AddSize 3650
562 SectionEnd
563
564 Section /o "Russian" SecTRussian
565  StrCpy $ThesCodes "ru_RU,$ThesCodes"
566  AddSize 2080
567 SectionEnd
568
569 Section /o "Sloven\9acina" SecTSlovenian
570  StrCpy $ThesCodes "sl_SI,$ThesCodes"
571  AddSize 1110
572 SectionEnd
573
574 Section /o "Slovenský" SecTSlovakian
575  StrCpy $ThesCodes "sk_SK,$ThesCodes"
576  AddSize 930
577 SectionEnd
578
579 Section /o "Svenska" SecTSwedish
580  StrCpy $ThesCodes "sv_SE,$ThesCodes"
581  AddSize 720
582 SectionEnd
583
584 Section /o "Ukrainian" SecTUkrainian
585  StrCpy $ThesCodes "uk_UA,$ThesCodes"
586  AddSize 1339
587 SectionEnd
588
589 SectionGroupEnd
590
591 # Section descriptions
592 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
593 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
594 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
595 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
596 !if ${SETUPTYPE} == BUNDLE
597  !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
598 !endif
599 !insertmacro MUI_DESCRIPTION_TEXT ${SecDictionaries} "$(SecDictionariesDescription)"
600 !insertmacro MUI_DESCRIPTION_TEXT ${SecThesaurus} "$(SecThesaurusDescription)"
601 !insertmacro MUI_FUNCTION_DESCRIPTION_END
602
603
604 # .onInit must be here after the section definition because we have to set
605 # the selection states of the dictionary sections
606 Function .onInit
607
608   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
609   ${if} $R0 == "5.0" # 2000
610   ${orif} $R0 == "5.1" # XP
611   ${orif} $R0 == "5.2" # 2003
612     MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} ${APP_VERSION} requires Windows Vista or newer." /SD IDOK
613     Quit
614   ${endif}
615   
616   # check that the installer is not currently running
617   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${BundleExeFile}.Instance") i .r1 ?e'
618   Pop $R0
619   ${if} $R0 != "0"
620    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)" /SD IDOK
621    Abort
622   ${endif}
623   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${ExeFile}.Instance") i .r1 ?e'
624   Pop $R0
625   ${if} $R0 != "0"
626    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)" /SD IDOK
627    Abort
628   ${endif}
629   
630   # FIXME: check that LyX is not currently running
631   #System::Call 'kernel32::CreateMutexA(i 0, i 0, t "LyX.exe.Instance") i .r1 ?e'
632   #Pop $R0
633   #MessageBox MB_OK "$R0"
634   #${if} $R0 != "0"
635   # MessageBox MB_OK|MB_ICONSTOP "$(LyXRunning)" 
636   # Abort
637   #${endif}
638   
639   # read the user and computer name
640   ReadRegStr $ComputerName HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
641   System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"
642   StrCpy $UserName $0
643   
644   !insertmacro MULTIUSER_INIT
645   
646   # check if this LyX version is already installed
647   ${if} $MultiUser.Privileges == "Admin"
648   ${orif} $MultiUser.Privileges == "Power"
649    ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayIcon"
650   ${else}
651    ReadRegStr $0 HKCU "${APP_UNINST_KEY}" "DisplayIcon"
652    # handle also the case that LyX is already installed in HKLM
653    ${if} $0 == ""
654     ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayIcon"
655    ${endif}
656   ${endif}
657   ${if} $0 != ""
658    # check if the uninstaller was acidentally deleted
659    # if so don't bother the user if he realy wants to install a new LyX over an existing one
660    # because he won't have a chance to deny this
661    StrCpy $4 $0 -10 # remove '\bin\lyx,0'
662    # (for FileCheck the variables $0 and $1 cannot be used)
663    !insertmacro FileCheck $5 "Uninstall-LyX.exe" "$4" # macro from LyXUtils.nsh
664    ${if} $5 == "False"
665     Goto ForceInstallation
666    ${endif}
667    # installing over an existing installation of the same LyX release is not necessary
668    # if the users does this he most probably has a problem with LyX that can better be solved
669    # by reinstalling LyX
670    # for beta and other test releases over-installing can even cause errors
671    MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONEXCLAMATION "$(AlreadyInstalled)" /SD IDNO IDYES ForceInstallation 
672    Abort
673    ForceInstallation:
674   ${endif}
675   
676   # check if there is an existing LyX installation of the same LyX series
677   # we usually don't release more than 10 versions so with 20 we are safe to check if a newer version is installed
678   IntOp $4 ${APP_VERSION_REVISION} + 20
679   ${for} $5 0 $4
680    ${if} $MultiUser.Privileges == "Admin"
681    ${orif} $MultiUser.Privileges == "Power"
682     ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$5" "DisplayVersion"
683     # also check for an emergency release
684     ${if} $0 == ""
685      ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$51" "DisplayVersion"
686     ${endif}
687    ${else}
688     ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$5" "DisplayVersion"
689     # also check for an emergency release
690     ${if} $0 == ""
691      ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$51" "DisplayVersion"
692     ${endif}
693    ${endif}
694    ${if} $0 != ""
695     StrCpy $R5 $0 # store the read version number
696     StrCpy $OldVersionNumber "${APP_VERSION_MAJOR}${APP_VERSION_MINOR}$5"
697     # we don't stop here because we want the latest installed version
698    ${endif} 
699   ${next}
700   
701   ${if} $OldVersionNumber > ${APP_SERIES_KEY}
702    # store the version number and reformat it temporarily for the error message
703    StrCpy $R0 $OldVersionNumber
704    StrCpy $OldVersionNumber $R5
705    MessageBox MB_OK|MB_ICONSTOP "$(NewerInstalled)" /SD IDOK
706    StrCpy $OldVersionNumber $R0
707    Abort
708   ${endif}
709
710   # this can be reset to "true" in section SecDesktop
711   StrCpy $CreateDesktopIcon "false"
712   StrCpy $CreateFileAssociations "false"
713  
714   ${IfNot} ${Silent}
715     # Show banner while installer is intializating 
716     Banner::show /NOUNLOAD "Checking system"
717   ${EndIf}
718  
719   Call SearchExternal
720   
721   !if ${SETUPTYPE} == BUNDLE
722    # don't let the installer sections appear when the programs are already installed
723    ${if} $PathBibTeXEditor != ""
724     SectionSetText 3 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
725    ${endif}
726   !endif
727   
728   # select sections of already installed spell-checker dictionaries, make them read-only
729   # and set the necessary size to 0 bytes
730   StrCpy $String $FoundDict
731   StrCpy $Search "af_ZA"
732   Call StrPoint # function from LyXUtils.nsh
733   ${if} $Pointer != "-1"
734    IntOp $0 ${SF_SELECTED} | ${SF_RO}
735    SectionSetFlags ${SecDAfrikaans} $0
736    SectionSetSize ${SecDAfrikaans} 0
737   ${endif}
738   StrCpy $Search "ar_DZ"
739   Call StrPoint
740   ${if} $Pointer != "-1"
741    IntOp $0 ${SF_SELECTED} | ${SF_RO}
742    SectionSetFlags ${SecDArabic} $0
743    SectionSetSize ${SecDArabic} 0
744   ${endif}
745   StrCpy $Search "hy_AM"
746   Call StrPoint
747   ${if} $Pointer != "-1"
748    IntOp $0 ${SF_SELECTED} | ${SF_RO}
749    SectionSetFlags ${SecDArmenian} $0
750    SectionSetSize ${SecDArmenian} 0
751   ${endif}
752   StrCpy $Search "id_ID"
753   Call StrPoint
754   ${if} $Pointer != "-1"
755    IntOp $0 ${SF_SELECTED} | ${SF_RO}
756    SectionSetFlags ${SecDIndonesian} $0
757    SectionSetSize ${SecDIndonesian} 0
758   ${endif}
759   StrCpy $Search "ms_MY"
760   Call StrPoint
761   ${if} $Pointer != "-1"
762    IntOp $0 ${SF_SELECTED} | ${SF_RO}
763    SectionSetFlags ${SecDMalayan} $0
764    SectionSetSize ${SecDMalayan} 0
765   ${endif}
766   StrCpy $Search "be_BY"
767   Call StrPoint
768   ${if} $Pointer != "-1"
769    IntOp $0 ${SF_SELECTED} | ${SF_RO}
770    SectionSetFlags ${SecDBelarusian} $0
771    SectionSetSize ${SecDBelarusian} 0
772   ${endif}
773   StrCpy $Search "br_FR"
774   Call StrPoint
775   ${if} $Pointer != "-1"
776    IntOp $0 ${SF_SELECTED} | ${SF_RO}
777    SectionSetFlags ${SecDBreton} $0
778    SectionSetSize ${SecDBreton} 0
779   ${endif}
780   StrCpy $Search "bg_BG"
781   Call StrPoint
782   ${if} $Pointer != "-1"
783    IntOp $0 ${SF_SELECTED} | ${SF_RO}
784    SectionSetFlags ${SecDBulgarian} $0
785    SectionSetSize ${SecDBulgarian} 0
786   ${endif}
787   StrCpy $Search "ca_ES"
788   Call StrPoint
789   ${if} $Pointer != "-1"
790    IntOp $0 ${SF_SELECTED} | ${SF_RO}
791    SectionSetFlags ${SecDCatalanian} $0
792    SectionSetSize ${SecDCatalanian} 0
793   ${endif}
794   StrCpy $Search "cs_CZ"
795   Call StrPoint
796   ${if} $Pointer != "-1"
797    IntOp $0 ${SF_SELECTED} | ${SF_RO}
798    SectionSetFlags ${SecDCzech} $0
799    SectionSetSize ${SecDCzech} 0
800   ${endif}
801  
802   StrCpy $Search "cop_EG"
803   Call StrPoint
804   ${if} $Pointer != "-1"
805    IntOp $0 ${SF_SELECTED} | ${SF_RO}
806    SectionSetFlags ${SecDCoptic} $0
807    SectionSetSize ${SecDCoptic} 0
808   ${endif}
809   StrCpy $Search "cy_GB"
810   Call StrPoint
811   ${if} $Pointer != "-1"
812    IntOp $0 ${SF_SELECTED} | ${SF_RO}
813    SectionSetFlags ${SecDWelsh} $0
814    SectionSetSize ${SecDWelsh} 0
815   ${endif}
816   StrCpy $Search "da_DK"
817   Call StrPoint
818   ${if} $Pointer != "-1"
819    IntOp $0 ${SF_SELECTED} | ${SF_RO}
820    SectionSetFlags ${SecDDanish} $0
821    SectionSetSize ${SecDDanish} 0
822   ${endif}
823   StrCpy $Search "de_AT"
824   Call StrPoint
825   ${if} $Pointer != "-1"
826    IntOp $0 ${SF_SELECTED} | ${SF_RO}
827    SectionSetFlags ${SecDGermanAT} $0
828    SectionSetSize ${SecDGermanAT} 0
829   ${endif}
830   StrCpy $Search "de_CH"
831   Call StrPoint
832   ${if} $Pointer != "-1"
833    IntOp $0 ${SF_SELECTED} | ${SF_RO}
834    SectionSetFlags ${SecDGermanCH} $0
835    SectionSetSize ${SecDGermanCH} 0
836   ${endif}
837   StrCpy $Search "de_DE"
838   Call StrPoint
839   ${if} $Pointer != "-1"
840    IntOp $0 ${SF_SELECTED} | ${SF_RO}
841    SectionSetFlags ${SecDGermanD} $0
842    SectionSetSize ${SecDGermanD} 0
843   ${endif}
844   StrCpy $Search "el_GR"
845   Call StrPoint
846   ${if} $Pointer != "-1"
847    IntOp $0 ${SF_SELECTED} | ${SF_RO}
848    SectionSetFlags ${SecDGreek} $0
849    SectionSetSize ${SecDGreek} 0
850   ${endif}
851   StrCpy $Search "et_EE"
852   Call StrPoint
853   ${if} $Pointer != "-1"
854    IntOp $0 ${SF_SELECTED} | ${SF_RO}
855    SectionSetFlags ${SecDEstonian} $0
856    SectionSetSize ${SecDEstonian} 0
857   ${endif}
858   StrCpy $Search "en_AU"
859   Call StrPoint
860   ${if} $Pointer != "-1"
861    IntOp $0 ${SF_SELECTED} | ${SF_RO}
862    SectionSetFlags ${SecDEnglishAU} $0
863    SectionSetSize ${SecDEnglishAU} 0
864   ${endif}
865   StrCpy $Search "en_CA"
866   Call StrPoint
867   ${if} $Pointer != "-1"
868    IntOp $0 ${SF_SELECTED} | ${SF_RO}
869    SectionSetFlags ${SecDEnglishCA} $0
870    SectionSetSize ${SecDEnglishCA} 0
871   ${endif}
872   StrCpy $Search "en_GB"
873   Call StrPoint
874   ${if} $Pointer != "-1"
875    IntOp $0 ${SF_SELECTED} | ${SF_RO}
876    SectionSetFlags ${SecDEnglishGB} $0
877    SectionSetSize ${SecDEnglishGB} 0
878   ${endif}
879   StrCpy $Search "en_NZ"
880   Call StrPoint
881   ${if} $Pointer != "-1"
882    IntOp $0 ${SF_SELECTED} | ${SF_RO}
883    SectionSetFlags ${SecDEnglishNZ} $0
884    SectionSetSize ${SecDEnglishNZ} 0
885   ${endif}
886   StrCpy $Search "en_US"
887   Call StrPoint
888   ${if} $Pointer != "-1"
889    IntOp $0 ${SF_SELECTED} | ${SF_RO}
890    SectionSetFlags ${SecDEnglishUS} $0
891    SectionSetSize ${SecDEnglishUS} 0
892   ${endif}
893   StrCpy $Search "es_ES"
894   Call StrPoint
895   ${if} $Pointer != "-1"
896    IntOp $0 ${SF_SELECTED} | ${SF_RO}
897    SectionSetFlags ${SecDSpanishES} $0
898    SectionSetSize ${SecDSpanishES} 0
899   ${endif}
900   StrCpy $Search "es_MX"
901   Call StrPoint
902   ${if} $Pointer != "-1"
903    IntOp $0 ${SF_SELECTED} | ${SF_RO}
904    SectionSetFlags ${SecDSpanishMX} $0
905    SectionSetSize ${SecDSpanishMX} 0
906   ${endif}
907   StrCpy $Search "eo_EO"
908   Call StrPoint
909   ${if} $Pointer != "-1"
910    IntOp $0 ${SF_SELECTED} | ${SF_RO}
911    SectionSetFlags ${SecDEsperanto} $0
912    SectionSetSize ${SecDEsperanto} 0
913   ${endif}
914   StrCpy $Search "eu_ES"
915   Call StrPoint
916   ${if} $Pointer != "-1"
917    IntOp $0 ${SF_SELECTED} | ${SF_RO}
918    SectionSetFlags ${SecDBasque} $0
919    SectionSetSize ${SecDBasque} 0
920   ${endif}
921   StrCpy $Search "fa_IR"
922   Call StrPoint
923   ${if} $Pointer != "-1"
924    IntOp $0 ${SF_SELECTED} | ${SF_RO}
925    SectionSetFlags ${SecDFarsi} $0
926    SectionSetSize ${SecDFarsi} 0
927   ${endif}
928   StrCpy $Search "fr_CA"
929   Call StrPoint
930   ${if} $Pointer != "-1"
931    IntOp $0 ${SF_SELECTED} | ${SF_RO}
932    SectionSetFlags ${SecDFrenchCanada} $0
933    SectionSetSize ${SecDFrenchCanada} 0
934   ${endif}
935   StrCpy $Search "fr_FR"
936   Call StrPoint
937   ${if} $Pointer != "-1"
938    IntOp $0 ${SF_SELECTED} | ${SF_RO}
939    SectionSetFlags ${SecDFrench} $0
940    SectionSetSize ${SecDFrench} 0
941   ${endif}
942   StrCpy $Search "ga_IR"
943   Call StrPoint
944   ${if} $Pointer != "-1"
945    IntOp $0 ${SF_SELECTED} | ${SF_RO}
946    SectionSetFlags ${SecDGaelic} $0
947    SectionSetSize ${SecDGaelic} 0
948   ${endif}
949   StrCpy $Search "gd_GB"
950   Call StrPoint
951   ${if} $Pointer != "-1"
952    IntOp $0 ${SF_SELECTED} | ${SF_RO}
953    SectionSetFlags ${SecDScottish} $0
954    SectionSetSize ${SecDScottish} 0
955   ${endif}
956   StrCpy $Search "gl_ES"
957   Call StrPoint
958   ${if} $Pointer != "-1"
959    IntOp $0 ${SF_SELECTED} | ${SF_RO}
960    SectionSetFlags ${SecDGalician} $0
961    SectionSetSize ${SecDGalician} 0
962   ${endif}
963   StrCpy $Search "he_IL"
964   Call StrPoint
965   ${if} $Pointer != "-1"
966    IntOp $0 ${SF_SELECTED} | ${SF_RO}
967    SectionSetFlags ${SecDHebrew} $0
968    SectionSetSize ${SecDHebrew} 0
969   ${endif}
970   StrCpy $Search "hi_IN"
971   Call StrPoint
972   ${if} $Pointer != "-1"
973    IntOp $0 ${SF_SELECTED} | ${SF_RO}
974    SectionSetFlags ${SecDHindi} $0
975    SectionSetSize ${SecDHindi} 0
976   ${endif}
977   StrCpy $Search "hr_HR"
978   Call StrPoint
979   ${if} $Pointer != "-1"
980    IntOp $0 ${SF_SELECTED} | ${SF_RO}
981    SectionSetFlags ${SecDCroatian} $0
982    SectionSetSize ${SecDCroatian} 0
983   ${endif}
984   StrCpy $Search "hu_HU"
985   Call StrPoint
986   ${if} $Pointer != "-1"
987    IntOp $0 ${SF_SELECTED} | ${SF_RO}
988    SectionSetFlags ${SecDHungarian} $0
989    SectionSetSize ${SecDHungarian} 0
990   ${endif}
991   StrCpy $Search "ia_IA"
992   Call StrPoint
993   ${if} $Pointer != "-1"
994    IntOp $0 ${SF_SELECTED} | ${SF_RO}
995    SectionSetFlags ${SecDInterlingua} $0
996    SectionSetSize ${SecDInterlingua} 0
997   ${endif}
998   StrCpy $Search "is_IS"
999   Call StrPoint
1000   ${if} $Pointer != "-1"
1001    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1002    SectionSetFlags ${SecDIcelandic} $0
1003    SectionSetSize ${SecDIcelandic} 0
1004   ${endif}
1005   StrCpy $Search "it_IT"
1006   Call StrPoint
1007   ${if} $Pointer != "-1"
1008    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1009    SectionSetFlags ${SecDItalian} $0
1010    SectionSetSize ${SecDItalian} 0
1011   ${endif}
1012   StrCpy $Search "kk_KZ"
1013   Call StrPoint
1014   ${if} $Pointer != "-1"
1015    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1016    SectionSetFlags ${SecDKazakh} $0
1017    SectionSetSize ${SecDKazakh} 0
1018   ${endif}
1019   StrCpy $Search "ko_KR"
1020   Call StrPoint
1021   ${if} $Pointer != "-1"
1022    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1023    SectionSetFlags ${SecDKorean} $0
1024    SectionSetSize ${SecDKorean} 0
1025   ${endif}
1026   StrCpy $Search "la_LA"
1027   Call StrPoint
1028   ${if} $Pointer != "-1"
1029    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1030    SectionSetFlags ${SecDLatin} $0
1031    SectionSetSize ${SecDLatin} 0
1032   ${endif}
1033   StrCpy $Search "lt_LT"
1034   Call StrPoint
1035   ${if} $Pointer != "-1"
1036    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1037    SectionSetFlags ${SecDLithuanian} $0
1038    SectionSetSize ${SecDLithuanian} 0
1039   ${endif}
1040   StrCpy $Search "lv_LV"
1041   Call StrPoint
1042   ${if} $Pointer != "-1"
1043    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1044    SectionSetFlags ${SecDLatvian} $0
1045    SectionSetSize ${SecDLatvian} 0
1046   ${endif}
1047   StrCpy $Search "mr_IN"
1048   Call StrPoint
1049   ${if} $Pointer != "-1"
1050    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1051    SectionSetFlags ${SecDMarathi} $0
1052    SectionSetSize ${SecDMarathi} 0
1053   ${endif}
1054   StrCpy $Search "nl_NL"
1055   Call StrPoint
1056   ${if} $Pointer != "-1"
1057    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1058    SectionSetFlags ${SecDDutch} $0
1059    SectionSetSize ${SecDDutch} 0
1060   ${endif}
1061   StrCpy $Search "nb_NO"
1062   Call StrPoint
1063   ${if} $Pointer != "-1"
1064    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1065    SectionSetFlags ${SecDNorwegianNB} $0
1066    SectionSetSize ${SecDNorwegianNB} 0
1067   ${endif}
1068   StrCpy $Search "nn_NO"
1069   Call StrPoint
1070   ${if} $Pointer != "-1"
1071    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1072    SectionSetFlags ${SecDNorwegianNN} $0
1073    SectionSetSize ${SecDNorwegianNN} 0
1074   ${endif}
1075   StrCpy $Search "oc_FR"
1076   Call StrPoint
1077   ${if} $Pointer != "-1"
1078    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1079    SectionSetFlags ${SecDOccitan} $0
1080    SectionSetSize ${SecDOccitan} 0
1081   ${endif}
1082   StrCpy $Search "pl_PL"
1083   Call StrPoint
1084   ${if} $Pointer != "-1"
1085    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1086    SectionSetFlags ${SecDPolish} $0
1087    SectionSetSize ${SecDPolish} 0
1088   ${endif}
1089   StrCpy $Search "pt_BR"
1090   Call StrPoint
1091   ${if} $Pointer != "-1"
1092    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1093    SectionSetFlags ${SecDPortugueseBR} $0
1094    SectionSetSize ${SecDPortugueseBR} 0
1095   ${endif}
1096   StrCpy $Search "pt_PT"
1097   Call StrPoint
1098   ${if} $Pointer != "-1"
1099    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1100    SectionSetFlags ${SecDPortuguesePT} $0
1101    SectionSetSize ${SecDPortuguesePT} 0
1102   ${endif}
1103   StrCpy $Search "ro_RO"
1104   Call StrPoint
1105   ${if} $Pointer != "-1"
1106    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1107    SectionSetFlags ${SecDRomanian} $0
1108    SectionSetSize ${SecDRomanian} 0
1109   ${endif}
1110   StrCpy $Search "ru_RU"
1111   Call StrPoint
1112   ${if} $Pointer != "-1"
1113    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1114    SectionSetFlags ${SecDRussian} $0
1115    SectionSetSize ${SecDRussian} 0
1116   ${endif}
1117   StrCpy $Search "dsb_DE"
1118   Call StrPoint
1119   ${if} $Pointer != "-1"
1120    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1121    SectionSetFlags ${SecDSorbianD} $0
1122    SectionSetSize ${SecDSorbianD} 0
1123   ${endif}
1124   StrCpy $Search "hsb_DE"
1125   Call StrPoint
1126   ${if} $Pointer != "-1"
1127    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1128    SectionSetFlags ${SecDSorbianH} $0
1129    SectionSetSize ${SecDSorbianH} 0
1130   ${endif}
1131   StrCpy $Search "sq_AL"
1132   Call StrPoint
1133   ${if} $Pointer != "-1"
1134    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1135    SectionSetFlags ${SecDAlbanian} $0
1136    SectionSetSize ${SecDAlbanian} 0
1137   ${endif}
1138   StrCpy $Search "sl_SI"
1139   Call StrPoint
1140   ${if} $Pointer != "-1"
1141    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1142    SectionSetFlags ${SecDSlovenian} $0
1143    SectionSetSize ${SecDSlovenian} 0
1144   ${endif}
1145   StrCpy $Search "sk_SK"
1146   Call StrPoint
1147   ${if} $Pointer != "-1"
1148    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1149    SectionSetFlags ${SecDSlovakian} $0
1150    SectionSetSize ${SecDSlovakian} 0
1151   ${endif}
1152   StrCpy $Search "sr_RS"
1153   Call StrPoint
1154   ${if} $Pointer != "-1"
1155    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1156    SectionSetFlags ${SecDSerbianC} $0
1157    SectionSetSize ${SecDSerbianC} 0
1158   ${endif}
1159   StrCpy $Search "sr_RS-Latin"
1160   Call StrPoint
1161   ${if} $Pointer != "-1"
1162    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1163    SectionSetFlags ${SecDSerbianL} $0
1164    SectionSetSize ${SecDSerbianL} 0
1165   ${endif}
1166   StrCpy $Search "sv_SE"
1167   Call StrPoint
1168   ${if} $Pointer != "-1"
1169    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1170    SectionSetFlags ${SecDSwedish} $0
1171    SectionSetSize ${SecDSwedish} 0
1172   ${endif}
1173   StrCpy $Search "ta_IN"
1174   Call StrPoint
1175   ${if} $Pointer != "-1"
1176    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1177    SectionSetFlags ${SecDTamil} $0
1178    SectionSetSize ${SecDTamil} 0
1179   ${endif}
1180   StrCpy $Search "te_IN"
1181   Call StrPoint
1182   ${if} $Pointer != "-1"
1183    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1184    SectionSetFlags ${SecDTelugu} $0
1185    SectionSetSize ${SecDTelugu} 0
1186   ${endif}
1187   StrCpy $Search "th_TH"
1188   Call StrPoint
1189   ${if} $Pointer != "-1"
1190    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1191    SectionSetFlags ${SecDThai} $0
1192    SectionSetSize ${SecDThai} 0
1193   ${endif}
1194   StrCpy $Search "bo_CN"
1195   Call StrPoint
1196   ${if} $Pointer != "-1"
1197    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1198    SectionSetFlags ${SecDTibetan} $0
1199    SectionSetSize ${SecDTibetan} 0
1200   ${endif}
1201   StrCpy $Search "tk_TM"
1202   Call StrPoint
1203   ${if} $Pointer != "-1"
1204    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1205    SectionSetFlags ${SecDTurkmen} $0
1206    SectionSetSize ${SecDTurkmen} 0
1207   ${endif}
1208   StrCpy $Search "tr_TR"
1209   Call StrPoint
1210   ${if} $Pointer != "-1"
1211    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1212    SectionSetFlags ${SecDTurkish} $0
1213    SectionSetSize ${SecDTurkish} 0
1214   ${endif}
1215   StrCpy $Search "uk_UA"
1216   Call StrPoint
1217   ${if} $Pointer != "-1"
1218    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1219    SectionSetFlags ${SecDUkrainian} $0
1220    SectionSetSize ${SecDUkrainian} 0
1221   ${endif}
1222   StrCpy $Search "ur_PK"
1223   Call StrPoint
1224   ${if} $Pointer != "-1"
1225    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1226    SectionSetFlags ${SecDUrdu} $0
1227    SectionSetSize ${SecDUrdu} 0
1228   ${endif}
1229   StrCpy $Search "vi_VN"
1230   Call StrPoint
1231   ${if} $Pointer != "-1"
1232    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1233    SectionSetFlags ${SecDVietnamese} $0
1234    SectionSetSize ${SecDVietnamese} 0
1235   ${endif}
1236   
1237   # select sections of already installed thesaurus dictionaries, make them read-only
1238   # and set the necessary size to 0 bytes
1239   StrCpy $String $FoundThes
1240   StrCpy $Search "bg_BG"
1241   Call StrPoint # function from LyXUtils.nsh
1242   ${if} $Pointer != "-1"
1243    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1244    SectionSetFlags ${SecTBulgarian} $0
1245    SectionSetSize ${SecTBulgarian} 0
1246   ${endif}
1247   StrCpy $Search "ca_ES"
1248   Call StrPoint
1249   ${if} $Pointer != "-1"
1250    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1251    SectionSetFlags ${SecTCatalan} $0
1252    SectionSetSize ${SecTCatalan} 0
1253   ${endif}
1254   StrCpy $Search "cs_CZ"
1255   Call StrPoint
1256   ${if} $Pointer != "-1"
1257    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1258    SectionSetFlags ${SecTCzech} $0
1259    SectionSetSize ${SecTCzech} 0
1260   ${endif}
1261   StrCpy $Search "da_DK"
1262   Call StrPoint
1263   ${if} $Pointer != "-1"
1264    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1265    SectionSetFlags ${SecTDanish} $0
1266    SectionSetSize ${SecTDanish} 0
1267   ${endif}
1268   StrCpy $Search "de_DE"
1269   Call StrPoint
1270   ${if} $Pointer != "-1"
1271    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1272    SectionSetFlags ${SecTGermanDA} $0
1273    SectionSetSize ${SecTGermanDA} 0
1274   ${endif} 
1275   StrCpy $Search "de_CH"
1276   Call StrPoint
1277   ${if} $Pointer != "-1"
1278    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1279    SectionSetFlags ${SecTGermanCH} $0
1280    SectionSetSize ${SecTGermanCH} 0
1281   ${endif}
1282   StrCpy $Search "en_AU"
1283   Call StrPoint
1284   ${if} $Pointer != "-1"
1285    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1286    SectionSetFlags ${SecTEnglishAU} $0
1287    SectionSetSize ${SecTEnglishAU} 0
1288   ${endif}
1289   StrCpy $Search "en_GB"
1290   Call StrPoint
1291   ${if} $Pointer != "-1"
1292    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1293    SectionSetFlags ${SecTEnglishGB} $0
1294    SectionSetSize ${SecTEnglishGB} 0
1295   ${endif} 
1296   StrCpy $Search "en_US"
1297   Call StrPoint
1298   ${if} $Pointer != "-1"
1299    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1300    SectionSetFlags ${SecTEnglishUS} $0
1301    SectionSetSize ${SecTEnglishUS} 0
1302   ${endif}
1303   StrCpy $Search "es_ES"
1304   Call StrPoint
1305   ${if} $Pointer != "-1"
1306    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1307    SectionSetFlags ${SecTSpanish} $0
1308    SectionSetSize ${SecTSpanish} 0
1309   ${endif}
1310   StrCpy $Search "fr_FR"
1311   Call StrPoint
1312   ${if} $Pointer != "-1"
1313    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1314    SectionSetFlags ${SecTFrench} $0
1315    SectionSetSize ${SecTFrench} 0
1316   ${endif}
1317   StrCpy $Search "ga_IR"
1318   Call StrPoint
1319   ${if} $Pointer != "-1"
1320    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1321    SectionSetFlags ${SecTGaelic} $0
1322    SectionSetSize ${SecTGaelic} 0
1323   ${endif}
1324   StrCpy $Search "gl_ES"
1325   Call StrPoint
1326   ${if} $Pointer != "-1"
1327    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1328    SectionSetFlags ${SecTGalician} $0
1329    SectionSetSize ${SecTGalician} 0
1330   ${endif}
1331   StrCpy $Search "el_GR"
1332   Call StrPoint
1333   ${if} $Pointer != "-1"
1334    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1335    SectionSetFlags ${SecTGreek} $0
1336    SectionSetSize ${SecTGreek} 0
1337   ${endif}
1338   StrCpy $Search "is_IS"
1339   Call StrPoint
1340   ${if} $Pointer != "-1"
1341    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1342    SectionSetFlags ${SecTIcelandic} $0
1343    SectionSetSize ${SecTIcelandic} 0
1344   ${endif}
1345   StrCpy $Search "it_IT"
1346   Call StrPoint
1347   ${if} $Pointer != "-1"
1348    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1349    SectionSetFlags ${SecTItalian} $0
1350    SectionSetSize ${SecTItalian} 0
1351   ${endif}
1352   StrCpy $Search "hu_HU"
1353   Call StrPoint
1354   ${if} $Pointer != "-1"
1355    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1356    SectionSetFlags ${SecTHungarian} $0
1357    SectionSetSize ${SecTHungarian} 0
1358   ${endif}
1359   StrCpy $Search "nb_NO"
1360   Call StrPoint
1361   ${if} $Pointer != "-1"
1362    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1363    SectionSetFlags ${SecTNorwegianNB} $0
1364    SectionSetSize ${SecTNorwegianNB} 0
1365   ${endif}
1366   StrCpy $Search "nn_NO"
1367   Call StrPoint
1368   ${if} $Pointer != "-1"
1369    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1370    SectionSetFlags ${SecTNorwegianNN} $0
1371    SectionSetSize ${SecTNorwegianNN} 0
1372   ${endif}
1373   StrCpy $Search "pl_PL"
1374   Call StrPoint
1375   ${if} $Pointer != "-1"
1376    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1377    SectionSetFlags ${SecTPolish} $0
1378    SectionSetSize ${SecTPolish} 0
1379   ${endif}
1380   StrCpy $Search "pt_PT"
1381   Call StrPoint
1382   ${if} $Pointer != "-1"
1383    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1384    SectionSetFlags ${SecTPortuguese} $0
1385    SectionSetSize ${SecTPortuguese} 0
1386   ${endif}
1387   StrCpy $Search "ro_RO"
1388   Call StrPoint
1389   ${if} $Pointer != "-1"
1390    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1391    SectionSetFlags ${SecTRomanian} $0
1392    SectionSetSize ${SecTRomanian} 0
1393   ${endif}
1394   StrCpy $Search "ru_RU"
1395   Call StrPoint
1396   ${if} $Pointer != "-1"
1397    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1398    SectionSetFlags ${SecTRussian} $0
1399    SectionSetSize ${SecTRussian} 0
1400   ${endif}
1401   StrCpy $Search "sl_SI"
1402   Call StrPoint
1403   ${if} $Pointer != "-1"
1404    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1405    SectionSetFlags ${SecTSlovenian} $0
1406    SectionSetSize ${SecTSlovenian} 0
1407   ${endif}
1408   StrCpy $Search "sk_SK"
1409   Call StrPoint
1410   ${if} $Pointer != "-1"
1411    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1412    SectionSetFlags ${SecTSlovakian} $0
1413    SectionSetSize ${SecTSlovakian} 0
1414   ${endif}
1415   StrCpy $Search "sv_SE"
1416   Call StrPoint
1417   ${if} $Pointer != "-1"
1418    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1419    SectionSetFlags ${SecTSwedish} $0
1420    SectionSetSize ${SecTSwedish} 0
1421   ${endif}
1422   StrCpy $Search "uk_UA"
1423   Call StrPoint
1424   ${if} $Pointer != "-1"
1425    IntOp $0 ${SF_SELECTED} | ${SF_RO}
1426    SectionSetFlags ${SecTUkrainian} $0
1427    SectionSetSize ${SecTUkrainian} 0
1428   ${endif}
1429   
1430   ${IfNot} ${Silent}
1431     Banner::destroy
1432   ${EndIf}
1433
1434 FunctionEnd
1435
1436 # this function is called at first after starting the uninstaller
1437 Function un.onInit
1438
1439   !insertmacro MULTIUSER_UNINIT
1440
1441   # Check that LyX is not currently running
1442   FindProcDLL::FindProc "lyx.exe"
1443   ${if} $R0 == "1"
1444    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)" /SD IDOK
1445    Abort
1446   ${endif}
1447
1448   # set registry root key
1449   ${if} $MultiUser.Privileges == "Admin"
1450   ${orif} $MultiUser.Privileges == "Power"
1451     SetShellVarContext all
1452   ${else}
1453    SetShellVarContext current
1454   ${endif}
1455
1456   # Ascertain whether the user has sufficient privileges to uninstall.
1457   # abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
1458   ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayVersion"
1459   ${if} $0 != ""
1460   ${andif} $MultiUser.Privileges != "Admin"
1461   ${andif} $MultiUser.Privileges != "Power"
1462    MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)" /SD IDOK
1463    Abort
1464   ${endif}
1465   # warning when LyX couldn't be found in the registry
1466   ${if} $0 == "" # check in HKCU
1467    ReadRegStr $0 HKCU "${APP_UNINST_KEY}" "DisplayVersion"
1468    ${if} $0 == ""
1469      MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)" /SD IDOK
1470    ${endif}
1471   ${endif}
1472   
1473   # Macro to investigate name of LyX's preferences folders to be able remove them
1474   !insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
1475
1476   # test if MiKTeX was installed together with LyX
1477   ReadRegStr $0 SHCTX "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
1478   ${if} $0 == "Yes${APP_SERIES_KEY}"
1479    SectionSetText 2 "MiKTeX" # names the corersponding uninstaller section
1480    StrCpy $LaTeXInstalled "MiKTeX"
1481   ${else}
1482    SectionSetText 2 "" # hides the corresponding uninstaller section
1483   ${endif}
1484   
1485   # test if JabRef was installed together with LyX
1486   ReadRegStr $0 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef" "OnlyWithLyX"
1487   ${if} $0 == "Yes${APP_SERIES_KEY}"
1488    SectionSetText 3 "JabRef" # names the corersponding uninstaller section
1489    StrCpy $JabRefInstalled "Yes"
1490   ${else}
1491    SectionSetText 3 "" # hides the corresponding uninstaller section
1492   ${endif}
1493
1494   # question message if the user really wants to uninstall LyX
1495   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" /SD IDYES IDYES +2 # continue if yes
1496   Abort
1497
1498 FunctionEnd
1499