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