1/*----------------------------------------------------------------------------------------------------- 2NSIS Installer script for OpenCPN (Windows) 3NSIS version 2.46 4Written by Gunther Pilz (Netsurfer) netsurfer@opencpn.de 5------------------------------------------------------------------------------------------------------- 6 7CMake variables 8 CPACK_PACKAGE_NAME "OpenCPN" 9 CPACK_NSIS_PACKAGE_NAME_LC "opencpn" 10 CPACK_PACKAGE_VENDOR "opencpn.org" 11 CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} 12 CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} 13 CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} 14 CPACK_PACKAGE_VERSION ${PACKAGE_VERSION} 15 CPACK_NSIS_INSTALLED_ICON_NAME "opencpn.exe" 16 CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/src/bitmaps\\\\opencpn.ico" 17 CPACK_NSIS_EXTRA_INSTALL_COMMANDS ${CPACK_NSIS_EXTRA_INSTALL_COMMANDS} 18 CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/data/license.txt" 19 CPACK_BUILDWIN_DIR "${CMAKE_SOURCE_DIR}/buildwin" 20 CPACK_NSIS_DIR "${CMAKE_SOURCE_DIR}/buildwin/NSIS_Unicode") 21 22 #CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${PACKAGE_NAME};ALL;/" 23 #CPACK_PACKAGE_EXECUTABLES ${PACKAGE_NAME} "OpenCPN" 24 #CPACK_PACKAGE_INSTALL_DIRECTORY ${PACKAGE_NAME} "OpenCPN" 25 #CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenCPN ${PACKAGE_VERSION}" 26 #CPACK_NSIS_LINK_NAME "${CPACK_PACKAGE_NAME} ${PACKAGE_VERSION}" 27 #CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME} Version ${PACKAGE_VERSION}" 28 #CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.opencpn.org" 29 #CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.opencpn.org" 30 #CPACK_NSIS_CONTACT "http:\\\\\\\\www.opencpn.org" 31 #CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}_setup" 32 33----------------------------------------------------------------------------------------------------------*/ 34; Enabled on MINGW builds: 35;!define NSIS_PACKEDVERSION true 36 37;# Set compression 38 SetCompressor /FINAL lzma 39!ifdef NSIS_PACKEDVERSION 40 Unicode true 41!endif 42 43 44;-------------------------------- 45;# You must define these values 46 !define OCPN_INSTALLER_VERSION "1.0.0" 47 /* 48 !define CPACK_NSIS_INSTALLED_ICON_NAME "opencpn.exe" 49 !define CPACK_NSIS_PACKAGE_NAME_LC "opencpn" 50 !define CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME} ${PACKAGE_VERSION}" 51 !define CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/src/bitmaps/opencpn.ico" 52 !define CPACK_BUILDWIN_DIR "${CMAKE_SOURCE_DIR}/buildwin" 53 !define CPACK_NSIS_DIR "${CMAKE_SOURCE_DIR}/buildwin/NSIS_Unicode" 54 */ 55 !define /date YEAR "%Y" 56 !define OUTPUT_FILE_NAME "@CPACK_NSIS_PACKAGE_NAME_LC@_@CPACK_PACKAGE_VERSION@_setup.exe" 57 !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@" 58 !define REG_ROOT_KEY "Software" 59 !define REG_KEY "Software\OpenCPN" 60 !define REG_ROOT_KEY_UN "Software\Microsoft\Windows\CurrentVersion\Uninstall" 61 !define REG_KEY_UN "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN @CPACK_PACKAGE_VERSION@" 62 !define CSIDL_LOCAL_APPDATA "0x1C" 63 !define Explode "!insertmacro Explode" 64 !define unExplode "!insertmacro unExplode" 65 66;-------------------------------- 67;# Variables 68 Var INST_USER_SID 69 Var CONFIG_EXISTS 70 Var CONFIG_EMPTY 71 Var INI_EXISTS 72 Var CHARTDB_EXISTS 73 Var SENC_EXISTS 74 Var CM93_EXISTS 75 Var NAVOBJ_EXISTS 76 Var LOG_EXISTS 77 Var REG_LANG 78 Var Count_SecGrpResetConfig 79 Var SecGrpEndSetConfig_Text 80 Var RESET_CONFIG 81 Var STARTMENU_FOLDER 82 Var OLD_INSTALLS 83 Var Prev_Install_RegKey 84 Var MULTIPLE_INSTALLS 85 Var VERSION_EXISTS 86 Var VERSION_NEWER 87 Var VERSION_OLDER 88 Var CANCEL_INSTALLER 89 Var VERSION_DATE 90 Var LANG_NAME 91 Var Status_SecGrpSetConfig 92 Var MAJOR_D 93 Var MINOR_D 94 Var PATCH_D 95 Var PATCH_ND 96 Var LM_VERSION 97 Var LM_VERSION_INST 98 Var LM_VERSION_UNINST 99 Var latest_version 100 Var latest_pathexe 101 Var BU_X 102 Var BU_Y 103 Var UAT 104 Var OUAT 105 Var USERS_APPDATA 106 Var ADMIN_APPDATA 107 Var USERS_NAME 108 Var counter_tmp 109 Var CurrentDirVar 110 Var CurrentFileVar 111 Var CONTEXT 112 Var REG_CHARTDIRS 113 Var USERNAME 114 Var IS_ADMIN 115 Var Compare_Version_Result 116 Var Inst_Or_Uninst 117 Var Marquee_Handle 118 Var Banner_Text_Blink 119 Var error_tmp 120# onSelChange 121 Var ConfigSetLang 122 Var ConfigSetChartDir 123 Var SetConfig 124# Installer Pages 125 Var Skip_Page_CleanUp 126 Var Skip_Page_TypeInst 127 Var Skip_Page_SetConfig 128 Var Skip_Page_Directory 129 Var Skip_Page_Startmenu 130 Var Skip_Page_Confirm 131# Page_TypeInst 132 Var Label_TypeInst_Reinstall 133 Var RB_Reinstall 134 Var Label_TypeInst_Upgrade 135 Var RB_Upgrade 136 Var Label_TypeInst_Downgrade 137 Var RB_Downgrade 138 Var Label_TypeInst_Parallel 139 Var GroupBox_TypeInst 140 Var RB_Parallel 141 Var TI_REINSTALL 142 Var TI_UPGRADE 143 Var TI_DOWNGRADE 144 Var TI_PARALLEL 145 Var GroupBox_Size 146 Var INSTALL_TYPE 147# Page_SetConfig 148 Var Label_SetConfig 149 Var GroupBox_Language_SetConfig 150 Var CheckBox_Language_SetConfig 151 Var GroupBox_ChartDir_SetConfig 152 Var DirRequest_SetConfig 153 Var Button_Delete_SetConfig 154 Var Button_DeleteAll_SetConfig 155 Var Button_Add_SetConfig 156 Var ListBox_SetConfig 157;# Page_SetConfig_Leave 158 Var CHART_DIR_TMP_FILE 159 Var CHART_DIR_EMPTY 160 Var CONFIG_SET_LANG 161 162# Uninstaller Pages 163 Var Skip_UnPage_Components 164;-------------------------------- 165;# Execution Level 166 RequestExecutionLevel highest 167 168;-------------------------------- 169;# Includes 170 !addincludedir "@CPACK_NSIS_DIR@/Include" 171 !addplugindir "@CPACK_NSIS_DIR@/Plugins" 172 173 !include MUI2.nsh 174 !include LogicLib.nsh 175 !include nsDialogs.nsh 176 !include Sections.nsh 177 !include StrFunc.nsh 178 !include WordFunc.nsh 179 !include TextFunc.nsh 180 !include FileFunc.nsh 181 !include WinVer.nsh 182 183 !include UAC.nsh 184 185 !define MUI_UI "@CPACK_NSIS_DIR@/UI/opencpn_ui.exe" 186 187;-------------------------------- 188;# General 189 ;# Name and file 190 Name "@CPACK_NSIS_PACKAGE_NAME@" 191 OutFile "@CPACK_TOPLEVEL_DIRECTORY@/${OUTPUT_FILE_NAME}" 192 193 ;# Default installation folder 194 InstallDir "$PROGRAMFILES\OpenCPN" 195 196 BrandingText /TRIMLEFT "OpenCPN $(Installer) v${OCPN_INSTALLER_VERSION}" 197;-------------------------------- 198;# Interface Settings 199 !define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit 200 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.myGuiInit 201 202 !define MUI_ABORTWARNING 203 204 ;# MUI Settings / Header 205 !define MUI_ICON "@CPACK_PACKAGE_ICON@" 206 !define MUI_HEADERIMAGE 207 !define MUI_HEADERIMAGE_LEFT 208 !define MUI_HEADERIMAGE_BITMAP "@CPACK_NSIS_DIR@\Bitmaps\header-install.bmp" 209 !define MUI_HEADERIMAGE_UNBITMAP "@CPACK_NSIS_DIR@\Bitmaps\header-uninstall.bmp" 210 211 ;# MUI Settings / Wizard 212 !define MUI_WELCOMEFINISHPAGE_BITMAP "@CPACK_NSIS_DIR@\Bitmaps\wizard-install.bmp" 213 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "@CPACK_NSIS_DIR@\Bitmaps\wizard-uninstall.bmp" 214 215 ;# Set Multi-Language settings 216 ;# Language Selection Dialog Settings 217 ;# Show all languages, despite user's codepage 218 !define MUI_LANGDLL_ALLLANGUAGES 219/* 220 ;# Remember the installer language 221 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM" 222 !define MUI_LANGDLL_REGISTRY_KEY "${REG_KEY_UN}" 223 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage" 224 !define MUI_LANGDLL_WINDOWTITLE "$(LangDialog_Title)" 225 !define MUI_LANGDLL_INFO "$(LangDialog_Text)" 226 */ 227;-------------------------------- 228;# Calls for making respective functions available 229 ${StrLoc} 230 231;-------------------------------- 232;################################################################################################## 233;# Macros # 234;################################################################################################## 235 236!ifndef ___EnumHKU___ 237 !define ___EnumHKU___ 238 239 !include LogicLib.nsh 240 !include WordFunc.nsh 241 242 !define TOKEN_QUERY 0x0008 243 !define TOKEN_ADJUST_PRIVILEGES 0x0020 244 245 !define SE_RESTORE_NAME SeRestorePrivilege 246 247 !define SE_PRIVILEGE_ENABLED 0x00000002 248 249 !define HKEY_USERS 0x80000003 250 251 Var key 252 Var logged 253 Var EnumHKU_counter 254 Var SID 255 Var USERPROFILE 256 257 !macro _EnumHKU_AdjustTokens 258 StrCpy $R1 0 259 260 System::Call "kernel32::GetCurrentProcess() i .R0" 261 System::Call "advapi32::OpenProcessToken(i R0, i ${TOKEN_QUERY}|${TOKEN_ADJUST_PRIVILEGES}, *i R1R1) i .R0" 262 263 ${If} $R0 != 0 264 System::Call "advapi32::LookupPrivilegeValue(t n, t '${SE_RESTORE_NAME}', *l .R2) i .R0" 265 266 ${If} $R0 != 0 267 System::Call "*(i 1, l R2, i ${SE_PRIVILEGE_ENABLED}) i .R0" 268 System::Call "advapi32::AdjustTokenPrivileges(i R1, i 0, i R0, i 0, i 0, i 0)" 269 System::Free $R0 270 ${EndIf} 271 272 System::Call "kernel32::CloseHandle(i R1)" 273 ${EndIf} 274 !macroend 275 276 !macro _EnumHKU_InvokeCallback CALLBACK SUBKEY 277 Push $0 278 Push $1 279 Push $R0 280 Push $R1 281 Push $R2 282 Push $R3 283 Push $R4 284 Push $R5 285 Push $R6 286 287 Push "${SUBKEY}" 288 Call "${CALLBACK}" 289 290 Pop $R6 291 Pop $R5 292 Pop $R4 293 Pop $R3 294 Pop $R2 295 Pop $R1 296 Pop $R0 297 Pop $1 298 Pop $0 299 !macroend 300 301 !macro _EnumHKU_Load FILE CALLBACK SUBKEY 302 GetFullPathName /SHORT $R2 ${FILE} 303 System::Call "advapi32::RegLoadKeyW(i ${HKEY_USERS}, t '${SUBKEY}', t R2) i .R3" 304 ${If} $R3 == 0 305 !insertmacro _EnumHKU_InvokeCallback ${CALLBACK} "${SUBKEY}" 306 ;System::Call "advapi32::RegUnLoadKeyW(i ${HKEY_USERS}, t '${SUBKEY}')" 307 IntOp $EnumHKU_counter $EnumHKU_counter + 1 308 ${EndIf} 309 !macroend 310 311 !macro EnumHKU UN CALLBACK SUBKEY 312 Push $0 313 Push $1 314 StrCpy $EnumHKU_counter 0 315 GetFunctionAddress $0 "${CALLBACK}" 316 StrCpy $1 "${SUBKEY}_$EnumHKU_counter" 317 StrCpy $key ${SUBKEY} 318 Call ${UN}_EnumHKU 319 Pop $1 320 Pop $0 321 !macroend 322 323 !define EnumHKU '!insertmacro EnumHKU ""' 324 !define un.EnumHKU '!insertmacro EnumHKU "un."' 325 326 !macro _EnumHKU UN 327 Function ${UN}_EnumHKU 328 Push $R0 329 Push $R1 330 Push $R2 331 Push $R3 332 Push $R4 333 Push $R5 334 Push $R6 335 336 # enumerate logged on users 337 StrCpy $R0 0 338 ${Do} 339 EnumRegKey $R1 HKU "" $R0 340 ${If} $R1 != "" 341 StrLen $R4 $R1 342 ${If} $R4 > 8 343 StrCpy $R6 0 344 ${WordFind} "$R1" "_Classes" "E*" $R6 345 IfErrors 0 cont 346 347 ReadRegStr $R5 HKU "$R1\Volatile Environment" USERPROFILE 348 ExpandEnvStrings $R5 $R5 349 StrCpy $USERPROFILE $R5 350 StrCpy $logged "on" 351 !insertmacro _EnumHKU_InvokeCallback $0 $R1 352 StrCpy $USERPROFILE "" 353 StrCpy $logged "" 354 ${EndIf} 355 cont: 356 IntOp $R0 $R0 + 1 357 ${EndIf} 358 ${LoopUntil} $R1 == "" 359 360 # enumerate logged off users 361 System::Call "kernel32::GetVersion() i .R0" 362 IntOp $R0 $R0 & 0x80000000 363 ${If} $R0 == 0 364 # nt 365 !insertmacro _EnumHKU_AdjustTokens 366 StrCpy $R0 0 367 ${Do} 368 EnumRegKey $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" $R0 369 ${If} $R1 != "" 370 StrLen $R4 $R1 371 ${If} $R4 > 8 372 ClearErrors 373 ReadRegStr $R5 HKU "$R1\Volatile Environment" HOMEPATH 374 IfErrors 0 cont1 375 ReadRegStr $R5 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$R1" ProfileImagePath 376 ExpandEnvStrings $R5 $R5 377 StrCpy $USERPROFILE $R5 378 StrCpy $logged "off" 379 !insertmacro _EnumHKU_Load "$R5\NTUSER.DAT" $0 $1 380 StrCpy $1 "$key_$EnumHKU_counter" 381 StrCpy $USERPROFILE "" 382 StrCpy $logged "" 383 ${EndIf} 384 385 cont1: 386 IntOp $R0 $R0 + 1 387 ${EndIf} 388 ${LoopUntil} $R1 == "" 389 ${Else} 390 # 9x 391 ClearErrors 392 FindFirst $R1 $R2 "$WINDIR\Profiles\*.*" 393 ${Unless} ${Errors} 394 ${Do} 395 ${If} $R2 != "." 396 ${AndIf} $R2 != ".." 397 ${If} ${FileExists} "$WINDIR\Profiles\$R2\USER.DAT" 398 !insertmacro _EnumHKU_Load "$WINDIR\Profiles\$R2\USER.DAT" $0 $1 399 ${EndIf} 400 ${EndIf} 401 ClearErrors 402 FindNext $R1 $R2 403 ${LoopUntil} ${Errors} 404 FindClose $R1 405 ${EndUnless} 406 ${Endif} 407 408 Pop $R6 409 Pop $R5 410 Pop $R4 411 Pop $R3 412 Pop $R2 413 Pop $R1 414 Pop $R0 415 FunctionEnd 416 !macroend 417 418 !insertmacro _EnumHKU "" 419 !insertmacro _EnumHKU "un." 420!endif 421 422!macro IndexOf Var Str Char 423 Push "${Char}" 424 Push "${Str}" 425 Call IndexOf 426 Pop "${Var}" 427!macroend 428!define IndexOf "!insertmacro IndexOf" 429 430!macro RIndexOf Var Str Char 431 Push "${Char}" 432 Push "${Str}" 433 Call RIndexOf 434 Pop "${Var}" 435!macroend 436!define RIndexOf "!insertmacro RIndexOf" 437 438 439!macro Explode Length Separator String 440 Push `${Separator}` 441 Push `${String}` 442 Call Explode 443 Pop `${Length}` 444!macroend 445 446!macro unExplode Length Separator String 447 Push `${Separator}` 448 Push `${String}` 449 Call un.Explode 450 Pop `${Length}` 451!macroend 452 453!ifndef _RecFind_Included 454 !define _RecFind_Included 455 456 Var _RecFindVar1 457 Var _RecFindVar2 458 459 !macro _RecFindOpen Dir CurrentDirVar CurrentFileVar 460 !define _Local `${__LINE__}` 461 !define _Dir `${Dir}` 462 !define _CurrentDirVar `${CurrentDirVar}` 463 !define _CurrentFileVar `${CurrentFileVar}` 464 465 !define _RecFindOpenSet 466 467 StrCpy $_RecFindVar2 1 468 Push `` 469 470 `nextDir${_Local}:` 471 Pop `${_CurrentDirVar}` 472 IntOp $_RecFindVar2 $_RecFindVar2 - 1 473 !macroend 474 !define RecFindOpen `!insertmacro _RecFindOpen` 475 476 !macro _RecFindFirst 477 !ifndef _RecFindOpenSet 478 !error `Incorrect use of RecFind commands!` 479 !else 480 !define _RecFindFirstSet 481 !endif 482 483 ClearErrors 484 FindFirst $_RecFindVar1 `${_CurrentFileVar}` `${_Dir}${_CurrentDirVar}\*.*` 485 IfErrors `Done${_Local}` 486 487 `checkFile${_Local}:` 488 StrCmp ${_CurrentFileVar} . `nextFile${_Local}` 489 StrCmp ${_CurrentFileVar} .. `nextFile${_Local}` 490 491 IfFileExists `${_Dir}${_CurrentDirVar}\${_CurrentFileVar}\*.*` 0 +4 492 Push `${_CurrentDirVar}\${_CurrentFileVar}` 493 IntOp $_RecFindVar2 $_RecFindVar2 + 1 494 Goto `nextFile${_Local}` 495 !macroend 496 !define RecFindFirst `!insertmacro _RecFindFirst` 497 498 !macro _RecFindNext 499 !ifndef _RecFindOpenSet | _RecFindFirstSet 500 !error `Incorrect use of RecFind commands!` 501 !else 502 !define _RecFindNextSet 503 !endif 504 505 `nextFile${_Local}:` 506 507 ClearErrors 508 FindNext $_RecFindVar1 `${_CurrentFileVar}` 509 IfErrors 0 `checkFile${_Local}` 510 511 StrCmp $_RecFindVar2 0 +3 512 FindClose $_RecFindVar1 513 Goto `nextDir${_Local}` 514 !macroend 515 !define RecFindNext `!insertmacro _RecFindNext` 516 517 !macro _RecFindClose 518 !ifndef _RecFindOpenSet | _RecFindFirstSet | _RecFindNextSet 519 !error `Incorrect use of RecFind commands!` 520 !else 521 !undef _RecFindOpenSet 522 !undef _RecFindFirstSet 523 !undef _RecFindNextSet 524 !endif 525 526 `Done${_Local}:` 527 FindClose $_RecFindVar1 528 529 StrCmp $_RecFindVar2 0 +4 530 Pop $_RecFindVar1 531 IntOp $_RecFindVar2 $_RecFindVar2 - 1 532 Goto -3 533 534 !undef _CurrentFileVar 535 !undef _CurrentDirVar 536 !undef _Dir 537 !undef _Local 538 !macroend 539 !define RecFindClose `!insertmacro _RecFindClose` 540!endif 541 542;-------------------------------------------------------------------------------------------------- 543;################################################################################################## 544;# PAGES # 545;################################################################################################## 546;# Installer Pages # 547;################################################################################################## 548/* Var Skip_Page_CleanUp 549 Var Skip_Page_TypeInst 550 Var Skip_Page_SetConfig 551 Var Skip_Page_Directory 552 Var Skip_Page_Startmenu 553 Var Skip_Page_Confirm 554*/ 555 ;# Welcome page 556 !define MUI_WELCOMEPAGE_TITLE_3LINES 557 !insertmacro MUI_PAGE_WELCOME 558 559 ;# License page 560 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE Page_License_Leave 561 ;!insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" 562 563 !define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)" 564 !define MUI_LICENSEPAGE_TEXT_BOTTOM $(License_Message) 565 566 !insertmacro MUI_PAGE_LICENSE $(license) 567 568 ;# Clean up page - only shown if previous installation(s) <= 2.2.823 were found - checked in .onInit function 569 Page custom Page_CleanUp Page_CleanUp_Leave 570 571 ;# Install type page - only shown if previous installation(s) > 2.2.823 were found - checked in .onInit function 572 Page custom Page_TypeInst Page_TypeInst_Leave 573 574 ;# Components page 575 !define MUI_COMPONENTSPAGE_SMALLDESC 576 !define MUI_PAGE_HEADER_TEXT $(CP_HEADER_TEXT) 577 !define MUI_PAGE_HEADER_SUBTEXT $(CP_HEADER_SUBTEXT) 578 !define MUI_COMPONENTSPAGE_TEXT_TOP $(CP_TOP) 579 !define MUI_COMPONENTSPAGE_TEXT_COMPLIST $(CP_COMPLIST) 580 !define MUI_COMPONENTSPAGE_TEXT_INSTTYPE "" ;#CHANGE $(CP_INSTTYPE) 581 ;!define MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_TITLE $(CP_DESCRIPTION_TITLE) ;# for this we can use the default text 582 ;!define MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_INFO $(CP_DESCRIPTION_INFO) ;# for this we can use the default text 583 !define MUI_PAGE_CUSTOMFUNCTION_PRE Page_Components_Pre 584 !define MUI_PAGE_CUSTOMFUNCTION_SHOW Page_Components_Show 585 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE Page_Components_Leave 586 !insertmacro MUI_PAGE_COMPONENTS 587 588 ;# Directory page - allows for changing/ selecting the install directory 589 !define MUI_DIRECTORYPAGE_VERIFYONLEAVE 590 !define MUI_PAGE_CUSTOMFUNCTION_PRE Page_Directory_Pre 591 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE Page_Directory_Leave 592 !insertmacro MUI_PAGE_DIRECTORY 593 594 ;# Start Menu Folder page - allows for changing/ selecting the Start Menu Folder (if Shortcuts get installed is configured on the Components page) 595 !define MUI_STARTMENUPAGE_NODISABLE 596 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" 597 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${REG_KEY_UN}" 598 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenuFolder" 599 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "OpenCPN" 600 !define MUI_PAGE_CUSTOMFUNCTION_PRE Page_Startmenu_Pre 601 !insertmacro MUI_PAGE_STARTMENU "Application" $STARTMENU_FOLDER 602 603 ;# Set Config page - selecting chart director[y|ies] and setting the language in opencpn.ini - only available if opencpn.ini does not exist (or is being deleted) 604 Page custom Page_SetConfig Page_SetConfig_Leave 605 606 ;# Confirm page - shows all settings for the installation (is mainly needed to always have the 'Install' button on the right page, ie. if Start Menu page is skipped) 607 Page custom Page_Confirm 608 609 ;# Install page 610 !define MUI_PAGE_CUSTOMFUNCTION_SHOW Page_Instfiles_Show 611 !insertmacro MUI_PAGE_INSTFILES 612 613 ;# Finish page 614 #!define MUI_FINISHPAGE_RUN opencpn.exe 615 !define MUI_FINISHPAGE_RUN 616 !define MUI_FINISHPAGE_RUN_FUNCTION ExecAppFile 617 618 !define MUI_FINISHPAGE_SHOWREADME install.log 619 !define MUI_FINISHPAGE_SHOWREADME_TEXT $(Show_Readme_Text) 620 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED 621 !define MUI_FINISHPAGE_LINK $(Finish_Link_Text) 622 !define MUI_FINISHPAGE_LINK_LOCATION $(Finish_Link_URL) 623 !define MUI_FINISHPAGE_LINK_COLOR 000080 624 !define MUI_FINISHPAGE_NOREBOOTSUPPORT 625 !define MUI_FINISHPAGE_TITLE_3LINES 626 !insertmacro MUI_PAGE_FINISH 627 628;-------------------------------- 629;################################################################################################## 630;# Uninstaller Pages # 631;################################################################################################## 632 ;# Welcome page 633 !define MUI_WELCOMEPAGE_TITLE_3LINES 634 !insertmacro MUI_UNPAGE_WELCOME 635 636 ;# Components page 637 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.Page_Components_Pre 638 !insertmacro MUI_UNPAGE_COMPONENTS 639 640 ;# Confirm page 641 !insertmacro MUI_UNPAGE_CONFIRM 642 ;# Uninstall page 643 !insertmacro MUI_UNPAGE_INSTFILES 644 645 ;# Finish page 646 !define MUI_FINISHPAGE_TITLE_3LINES 647 !insertmacro MUI_UNPAGE_FINISH 648 649;-------------------------------------------------------------------------------------------------- 650;################################################################################################## 651;# Languages # 652;################################################################################################## 653;# Languages 654 !insertmacro MUI_LANGUAGE "English" ;# first language is the default language 655 !insertmacro MUI_LANGUAGE "German" 656 !include /NONFATAL "Langstrings_GERMAN.nsh" 657 !insertmacro MUI_LANGUAGE "French" 658 !include /NONFATAL "Langstrings_FRENCH.nsh" 659 !insertmacro MUI_LANGUAGE "Czech" 660 !include /NONFATAL "Langstrings_CZECH.nsh" 661 !insertmacro MUI_LANGUAGE "Danish" 662 !include /NONFATAL "Langstrings_DANISH.nsh" 663 !insertmacro MUI_LANGUAGE "Spanish" 664 !include /NONFATAL "Langstrings_SPANISH.nsh" 665 !insertmacro MUI_LANGUAGE "Italian" 666 !include /NONFATAL "Langstrings_ITALIAN.nsh" 667 !insertmacro MUI_LANGUAGE "Dutch" 668 !include /NONFATAL "Langstrings_DUTCH.nsh" 669 !insertmacro MUI_LANGUAGE "Polish" 670 !include /NONFATAL "Langstrings_POLISH.nsh" 671 !insertmacro MUI_LANGUAGE "PortugueseBR" 672 !include /NONFATAL "Langstrings_PORTUGUESEBR.nsh" 673 !insertmacro MUI_LANGUAGE "Portuguese" 674 !include /NONFATAL "Langstrings_PORTUGUESE.nsh" 675 !insertmacro MUI_LANGUAGE "Russian" 676 !include /NONFATAL "Langstrings_RUSSIAN.nsh" 677 !insertmacro MUI_LANGUAGE "Swedish" 678 !include /NONFATAL "Langstrings_SWEDISH.nsh" 679 !insertmacro MUI_LANGUAGE "Finnish" 680 !include /NONFATAL "Langstrings_FINNISH.nsh" 681 !insertmacro MUI_LANGUAGE "Norwegian" 682 !include /NONFATAL "Langstrings_NORWEGIAN.nsh" 683 !insertmacro MUI_LANGUAGE "TradChinese" 684 !include /NONFATAL "Langstrings_CHINESETW.nsh" 685 !insertmacro MUI_LANGUAGE "Turkish" 686 !include /NONFATAL "Langstrings_TURKISH.nsh" 687 ;!insertmacro MUI_LANGUAGE "Hungarian" 688 ;!include /NONFATAL "Langstrings_HUNGARIAN.nsh" 689 690;-------------------------------- 691;# Reserve Files 692 ;# If you are using solid compression, files that are required before 693 ;# the actual installation should be stored first in the data block, 694 ;# because this will make your installer start faster. 695 !insertmacro MUI_RESERVEFILE_LANGDLL 696 697;# Remember the installer language 698 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM" 699 !define MUI_LANGDLL_REGISTRY_KEY "${REG_KEY_UN}" 700 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage" 701 !define MUI_LANGDLL_WINDOWTITLE $(LangDialog_Title) 702 !define MUI_LANGDLL_INFO $(LangDialog_Text) 703 704;-------------------------------------------------------------------------------------------------- 705;################################################################################################## 706;# S E C T I O N S # 707;################################################################################################## 708;# Installer Sections # 709;################################################################################################## 710Section "-Topmost Section" SecTopmost ;# this needs to be always the first section to be executed! 711 SetShellVarContext all 712 SetOutPath $INSTDIR 713;!ifndef NSIS_PACKEDVERSION 714; LogSet on 715;!endif 716 ${If} $INSTALL_TYPE == 1 717 ${OrIf} $INSTALL_TYPE == 2 718 ${OrIf} $INSTALL_TYPE == 3 719 ReadRegStr $0 HKLM "$Prev_Install_RegKey" "UninstallString" 720 ${StrFilter} "$0" "" "" "$\"" $0 721 ClearErrors 722 ExecWait '"$0" /S /type=1 _?=$INSTDIR' 723 IfErrors 0 +2 724 DetailPrint "Error on uninstalling" 725 Sleep 100 726 Delete $0 727 ${EndIf} 728SectionEnd 729 730;# Reset/ Delete Config Section 731SectionGroup "!Reset Config Section Group" SecGrpResetConfig 732 Section /o "Delete Config File Section" SecDeleteConfigFile 733 ;# Delete config file (opencpn.ini) 734 SetShellVarContext all 735 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" 736 Delete "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" 737 ClearErrors 738 ${EndIf} 739 SectionEnd 740 741 Section /o "Delete ChartDB Section" SecDeleteChartDB 742 ;# Delete chart DB (CHRTLIST.DAT) 743 SetShellVarContext all 744 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\CHRTLIST.DAT" 745 Delete "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\CHRTLIST.DAT" 746 ClearErrors 747 ${EndIf} 748 SectionEnd 749 750 Section /o "Delete SENC Section" SecDeleteSENC 751 ;# Delete SENC directory 752 SetShellVarContext all 753 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\SENC\*.*" 754 RMDir /r "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\SENC" 755 ClearErrors 756 ${EndIf} 757 SectionEnd 758 759 Section /o "Delete SENC Section" SecDeleteCM93 760 ;# Delete SENC directory 761 SetShellVarContext all 762 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\cm93\*.*" 763 RMDir /r "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\cm93" 764 ClearErrors 765 ${EndIf} 766 SectionEnd 767 768 Section /o "Delete Navobject Section" SecDeleteNavobjFile 769 ;# Delete navobject file (navobj.xml) 770 SetShellVarContext all 771 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\navobj.xml" 772 Delete "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\navobj.xml" 773 ClearErrors 774 ${EndIf} 775 SectionEnd 776 777 Section /o "Delete Log File Section" SecDeleteLogFile 778 ;# Delete log file (opencpn.log) 779 SetShellVarContext all 780 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.log" 781 Delete "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.log" 782 ClearErrors 783 ${EndIf} 784 SectionEnd 785SectionGroupEnd 786 787;# Shortcut Section 788SectionGroup /e "!Shortcuts Section Group" SecGrpShortcuts 789 Section "Startmenu Shortcut Section" SecShortcutStartmenu 790 ;# Start Menu 791 SetShellVarContext all 792 SetOutPath $INSTDIR 793 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 794 ;# Create shortcuts 795 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" 796 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\OpenCPN @CPACK_PACKAGE_VERSION@.lnk" "$INSTDIR\opencpn.exe" 797 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\OpenCPN @CPACK_PACKAGE_VERSION@ - No OpenGL.lnk" "$INSTDIR\opencpn.exe" "/no_opengl" 798 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER\$(Uninstall_Folder_Name)" 799 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\$(Uninstall_Folder_Name)\$(Uninstall_Link).lnk" "$INSTDIR\Uninstall @CPACK_PACKAGE_VERSION@.exe" 800 !insertmacro MUI_STARTMENU_WRITE_END 801 SectionEnd 802 803 Section "Desktop Shortcut Section" SecShortcutDesktop 804 SetShellVarContext all 805 CreateShortCut "$DESKTOP\OpenCPN @CPACK_PACKAGE_VERSION@.lnk" "$INSTDIR\opencpn.exe" 806 SectionEnd 807SectionGroupEnd 808 809;# Write Config Section 810Section "!Set Config Section" SecSetConfig 811 ;# Write settings for config file (opencpn.ini) to HKLM Software\OpenCPN 812 ${If} $CONFIG_SET_LANG == 1 813 ;Call Write_Reg_Lang 814 WriteRegStr HKLM "Software\OpenCPN" "InstallerLanguage" $REG_LANG 815 ${EndIf} 816 817 ${If} $CHART_DIR_TMP_FILE == 1 818 Call Write_Reg_ChartDirs 819 ${EndIf} 820SectionEnd 821 822 823;# Install Section /hidden 824Section "-Install Section" SecInstall 825 @CPACK_NSIS_FULL_INSTALL@ 826 827 @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@ 828 829 ;# Create uninstaller 830 WriteUninstaller "$INSTDIR\Uninstall @CPACK_PACKAGE_VERSION@.exe" 831 832 ;# Registry Entries 833 SetShellVarContext all ;# make sure that we write to HKLM 834 ;# HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN <DisplayVersion> 835 WriteRegStr SHCTX "${REG_KEY_UN}" "DisplayName" "@CPACK_PACKAGE_NAME@ @CPACK_PACKAGE_VERSION@" 836 WriteRegStr SHCTX "${REG_KEY_UN}" "DisplayVersion" "@CPACK_PACKAGE_VERSION@" 837 WriteRegStr SHCTX "${REG_KEY_UN}" "CompareVersion" "$VERSION_DATE" 838 WriteRegStr SHCTX "${REG_KEY_UN}" "StartMenuPath" "$SMPROGRAMS\$STARTMENU_FOLDER" 839 WriteRegStr SHCTX "${REG_KEY_UN}" "InstallLocation" "$INSTDIR" 840 WriteRegStr SHCTX "${REG_KEY_UN}" "UninstallString" "$\"$INSTDIR\Uninstall @CPACK_PACKAGE_VERSION@.exe$\"" 841 WriteRegStr SHCTX "${REG_KEY_UN}" "QuietUninstallString" "$\"$INSTDIR\Uninstall @CPACK_PACKAGE_VERSION@.exe /S$\"" 842 WriteRegStr SHCTX "${REG_KEY_UN}" "ConfigLocation" "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" 843 WriteRegStr SHCTX "${REG_KEY_UN}" "DisplayIcon" "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" 844 WriteRegStr SHCTX "${REG_KEY_UN}" "Publisher" "@CPACK_PACKAGE_VENDOR@" 845 WriteRegDWORD SHCTX "${REG_KEY_UN}" "VersionMajor" $MAJOR_D 846 WriteRegDWORD SHCTX "${REG_KEY_UN}" "VersionMinor" $MINOR_D 847 WriteRegDWORD SHCTX "${REG_KEY_UN}" "VersionPatch" $PATCH_D 848 WriteRegDWORD SHCTX "${REG_KEY_UN}" "NoModify" 1 849 WriteRegDWORD SHCTX "${REG_KEY_UN}" "NoRepair" 1 850 WriteRegStr SHCTX "${REG_KEY_UN}" "HelpLink" "http://opencpn.org/" 851 WriteRegStr SHCTX "${REG_KEY_UN}" "URLInfoAbout" "http://opencpn.org/" 852 WriteRegStr SHCTX "${REG_KEY_UN}" "Contact" "http://opencpn.org/" 853 WriteRegStr SHCTX "${REG_KEY_UN}" "InstallUser" "$USERS_NAME" 854 ${If} ${UAC_IsInnerInstance} 855 WriteRegStr SHCTX "${REG_KEY_UN}" "InstallAdminUser" "$USERNAME" 856 ${EndIf} 857 858 ;# Create the config folder if it does not exist and set full access rights to it 859 ${IfNot} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" 860 CreateDirectory "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" 861 Sleep 250 862 ${EndIf} 863 AccessControl::GrantOnFile "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" "(BU)" "GenericRead + GenericExecute + GenericWrite + Delete + FullAccess" 864 865 ;# Save the log file 866 StrCpy $0 "$INSTDIR\install.log" 867 Push $0 868 IfSilent +2 0 869 Call DumpLog 870SectionEnd 871 872;-------------------------------- 873;################################################################################################## 874;# Uninstaller Sections # 875;################################################################################################## 876 877Section "-un.Delete Config RegKey" UnSecDeleteConfigRegKey 878 DeleteRegKey HKLM "${REG_KEY}" 879SectionEnd 880 881Section /o "-un.Backup Config to RegKey" UnSecBackupConfigToRegKey 882 SetShellVarContext all 883 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" 884 ClearErrors 885 StrCpy $0 "" 886 StrCpy $2 0 887 loop: 888 IntOp $2 $2 + 1 889 ReadINIStr $1 "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" "ChartDirectories" "ChartDir$2" 890 StrCmp $1 "" cont 891 ${WordReplace} "$1" "\\" "\" "+" $3 892 ${unExplode} $4 "^" "$3" 893 Pop $5 894 StrCmp $5 "" cont 895 StrCmp $0 "" 0 +2 896 StrCpy $0 $5 897 StrCpy $0 "$0;$5" 898 Goto loop 899 cont: 900 WriteRegStr HKLM "${REG_KEY}" "ChartDirs" "$0" 901 902 ReadINIStr $0 "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" "Settings" "Locale" 903 StrCmp $0 "" +2 0 904 WriteRegStr HKLM "${REG_KEY}" "InstallerLanguage" "$0" 905 ${EndIf} 906SectionEnd 907 908Section "un.Delete Config Folder" UnSecDeleteConfigFolder 909 SetShellVarContext all 910 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" 911 RMDir /r "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" 912 ClearErrors 913 ${EndIf} 914SectionEnd 915 916Section "-un.Uninstall" UnSecUninstall 917 ;# Delete all Shortcuts 918 Push $INSTDIR 919 Call un.Delete_Desktop_Shortcuts 920 Push $INSTDIR 921 Call un.Delete_Start_Menu_Shortcuts 922 923 ;# Delete subdirs and files in INSTDIR 924 ;# Remove the uninstaller itself 925 ReadRegStr $0 HKLM "${REG_KEY_UN}" "UninstallString" 926 ${StrFilter} "$0" "" "" "$\"" $0 927 Delete $0 928 ;# Remove the installation log file 929 Delete "$INSTDIR\install.log" 930 @CPACK_NSIS_DELETE_FILES@ 931 @CPACK_NSIS_DELETE_DIRECTORIES@ 932 933 ;# Remove the installation directory INSTDIR if it is empty 934 ClearErrors 935 RMDir "$INSTDIR" 936 IfErrors 0 cont 937 IfSilent cont 938 MessageBox MB_OK|MB_ICONEXCLAMATION "$(Msg_Error_Remove_InstDir)" 939 940 cont: 941 ;# Remove RegKey 942 DeleteRegKey HKLM "${REG_KEY_UN}" 943SectionEnd 944 945;-------------------------------------------------------------------------------------------------- 946;################################################################################################## 947;# F U N C T I O N S # 948;################################################################################################## 949;# Installer Functions # 950;################################################################################################## 951;# .onInit Function 952Function .onInit 953 ;# Check if Windows version is at least XP (not Win 98, Win 2000 or older) 954 ${IfNot} ${AtLeastWinXP} 955 MessageBox MB_OK|MB_ICONEXCLAMATION "$(Installer_Unsupported_Windows_Version)" 956 Abort 957 ${Else} 958 ${If} ${IsWinXP} 959 ${AndIf} ${AtMostServicePack} 2 960 MessageBox MB_OK|MB_ICONEXCLAMATION "$(Installer_Unsupported_XP_SP_Version)" 961 Abort 962 ${EndIf} 963 ${EndIf} 964 965 ;Prevent multiple instances of the installer 966 ${IfNot} ${UAC_IsInnerInstance} 967 System::Call 'kernel32::CreateMutexW(i 0, i 0, t "ocpn_inst_@CPACK_PACKAGE_VERSION@") i .r1 ?e' 968 Pop $R0 969 StrCmp $R0 0 +3 970 MessageBox MB_OK|MB_ICONEXCLAMATION "$(Installer_Running)" 971 Abort 972 ${EndIf} 973 974 Call GetUserInfo 975 StrCpy $USERS_NAME $USERNAME 976 977 ;# Macros to be inserted 978 ${If} $IS_ADMIN == 1 979 !insertmacro MUI_LANGDLL_DISPLAY 980 ${EndIf} 981 982 SetShellVarContext current 983 StrCpy $USERS_APPDATA $APPDATA 984 StrCpy $ADMIN_APPDATA $APPDATA 985 986 ;# UAC check if user has Admin privileges and prompt for elevation if not 987 uac_tryagain: 988 !insertmacro UAC_RunElevated 989 StrCpy $Inst_Or_Uninst "$(Installer)" 990 ${Switch} $0 991 ${Case} 0 992 ${IfThen} $1 = 1 ${|} Quit ${|} ;# we are the outer process, the inner process has done its work, we are done 993 ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;# we are admin, let the show go on 994 ${If} $1 = 3 ;# RunAs completed successfully, but with a non-admin user 995 MessageBox mb_IconExclamation|mb_TopMost|mb_SetForeground "$(Msg_UAC_Admin_Retry)" /SD IDNO IDOK uac_tryagain IDNO 0 996 ${EndIf} 997 ;# fall-through and die 998 ${Case} 1223 999 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(Msg_UAC_Admin_Abort)" 1000 Quit 1001 ${Case} 1062 1002 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(Msg_UAC_Logon_Abort)" 1003 Quit 1004 ${Default} 1005 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(Msg_UAC_No_Elevation)" 1006 Quit 1007 ${EndSwitch} 1008 1009########## from here we can be sure to run with admin privileges ########## 1010 1011 ;# Delete all temporary files created during the installation 1012 Delete "$TEMP\opencpn_*.tmp" 1013 ;DeleteRegKey HKCU "Software\OpenCPN" ;# remove RegKey possibly exists - was used by versions 2.2.808 to 2.2.823 1014 1015 ;# Check for unloaded Registry hive from previous installation attempt e.g. when installer crashed 1016 StrCpy $0 0 1017 !insertmacro _EnumHKU_AdjustTokens 1018 ${Do} 1019 EnumRegKey $1 HKU "" $0 1020 StrCmp $1 "" done 1021 IntOp $0 $0 + 1 1022 ClearErrors 1023 ${WordFind} "$1" "opencpn-inst-tmp-sid" "E*" $2 1024 IfErrors +2 0 1025 System::Call "advapi32::RegUnLoadKeyW(i ${HKEY_USERS}, t '$1') i .r3" 1026 ${Loop} 1027 done: 1028 ${If} ${UAC_IsInnerInstance} 1029 !insertmacro UAC_AsUser_GetGlobalVar $USERS_APPDATA 1030 !insertmacro UAC_AsUser_GetGlobalVar $USERS_NAME 1031 ${EndIf} 1032 1033 ClearErrors 1034 Var /GLOBAL INST_PARAMS 1035 Var /GLOBAL FORCE_SCAN 1036 ${GetParameters} $INST_PARAMS 1037 ${GetOptions} "$INST_PARAMS" "/scan" $FORCE_SCAN 1038 IfErrors +2 1039 1040 # Get the user's SID from the username 1041 ReadRegStr $0 HKCU "Volatile Environment" "USERNAME" 1042 System::Call /NOUNLOAD '*(&w${NSIS_MAX_STRLEN})i.R9' 1043 System::Call /NOUNLOAD 'advapi32::LookupAccountNameW(,t "$0",i R9,*i ${NSIS_MAX_STRLEN},w .R8,*i ${NSIS_MAX_STRLEN},*i .r4)i.r5' 1044 System::Call /NOUNLOAD 'advapi32::ConvertSidToStringSidW(i R9,*t .R8)i.r5' 1045 StrCpy $INST_USER_SID $R8 1046 1047 Call VersionDate 1048 1049 ;# check for previous installed versions conforming to this installer 1050 Call Check_Prev_Installs 1051 1052 ;# check for old installed versions prior to the ones that uses this installer 1053 StrCpy $OLD_INSTALLS 0 1054 1055 Call Reg_Scan_Old_Versions_HKLM 1056 1057 Call EnumProfileList 1058 1059 Call Get_Users_Values 1060 1061 ${If} $OLD_INSTALLS == 0 1062 StrCpy $Skip_Page_CleanUp 1 1063 ${EndIf} 1064 1065 1066 ;# make sure that the DWORD values for the Registry only contain digits 1067 ${StrFilter} "@CPACK_PACKAGE_VERSION_MAJOR@" "1" "" "" $MAJOR_D 1068 ${StrFilter} "@CPACK_PACKAGE_VERSION_MINOR@" "1" "" "" $MINOR_D 1069 ${StrFilter} "@CPACK_PACKAGE_VERSION_PATCH@" "1" "" "" $PATCH_D 1070 1071 ;Call GetAllUsers 1072FunctionEnd 1073 1074;-------------------------------- 1075;# myGuiInit Function 1076/* 1077Var CONFIG_EMPTY 1078Var INI_EXISTS 1079Var CHARTDB_EXISTS 1080Var SENC_EXISTS 1081Var CM93_EXISTS 1082Var NAVOBJ_EXISTS 1083Var LOG_EXISTS 1084Var REG_LANG 1085Var Count_SecGrpResetConfig 1086Var SecGrpEndSetConfig_Text 1087*/ 1088Function myGuiInit 1089 ;Get chosen installer language 1090 ${Switch} $LANGUAGE 1091 ${Case} ${LANG_CZECH} 1092 StrCpy $LANG_NAME "Čeština" 1093 StrCpy $REG_LANG "cs_CZ" 1094 ${Break} 1095 ${Case} ${LANG_DANISH} 1096 StrCpy $LANG_NAME "Dansk" 1097 StrCpy $REG_LANG "da_DK" 1098 ${Break} 1099 ${Case} ${LANG_GERMAN} 1100 StrCpy $LANG_NAME "Deutsch" 1101 StrCpy $REG_LANG "de_DE" 1102 ${Break} 1103 ${Case} ${LANG_ENGLISH} 1104 StrCpy $LANG_NAME "English" 1105 StrCpy $REG_LANG "en_US" 1106 ${Break} 1107 ${Case} ${LANG_SPANISH} 1108 StrCpy $LANG_NAME "Español" 1109 StrCpy $REG_LANG "es_ES" 1110 ${Break} 1111 ${Case} ${LANG_FRENCH} 1112 StrCpy $LANG_NAME "Français" 1113 StrCpy $REG_LANG "fr_FR" 1114 ${Break} 1115 ${Case} ${LANG_ITALIAN} 1116 StrCpy $LANG_NAME "Italiano" 1117 StrCpy $REG_LANG "it_IT" 1118 ${Break} 1119 ${Case} ${LANG_DUTCH} 1120 StrCpy $LANG_NAME "Nederlandse" 1121 StrCpy $REG_LANG "nl_NL" 1122 ${Break} 1123 ${Case} ${LANG_POLISH} 1124 StrCpy $LANG_NAME "Polski" 1125 StrCpy $REG_LANG "pl_PL" 1126 ${Break} 1127 ${Case} ${LANG_PORTUGUESE} 1128 StrCpy $LANG_NAME "Português" 1129 StrCpy $REG_LANG "pt_PT" 1130 ${Break} 1131 ${Case} ${LANG_PORTUGUESEBR} 1132 StrCpy $LANG_NAME "Português Brasileiro" 1133 StrCpy $REG_LANG "pt_BR" 1134 ${Break} 1135 ${Case} ${LANG_SWEDISH} 1136 StrCpy $LANG_NAME "Svenska" 1137 StrCpy $REG_LANG "sv_SE" 1138 ${Break} 1139 ${Case} ${LANG_RUSSIAN} 1140 StrCpy $LANG_NAME "Русский" 1141 StrCpy $REG_LANG "ru_RU" 1142 ${Break} 1143 ${Case} ${LANG_NORWEGIAN} 1144 StrCpy $LANG_NAME "Norsk" 1145 StrCpy $REG_LANG "nb_NO" 1146 ${Break} 1147 ${Case} ${LANG_FINNISH} 1148 StrCpy $LANG_NAME "Suomalainen" 1149 StrCpy $REG_LANG "fi_FI" 1150 ${Break} 1151 ${Case} ${LANG_TRADCHINESE} 1152 StrCpy $LANG_NAME "正體中文" 1153 StrCpy $REG_LANG "zh_TW" 1154 ${Break} 1155 ${Case} ${LANG_Turkish} 1156 StrCpy $LANG_NAME "Türkçe" 1157 StrCpy $REG_LANG "tr_TR" 1158 ${Break} 1159 ${Default} 1160 ${Break} 1161 ${EndSwitch} 1162 1163 ;# Set Sections Text 1164 SectionSetText ${SecGrpShortcuts} $(SecGrpShortcuts_Text) 1165 SectionSetText ${SecShortcutStartmenu} $(SecShortcutStartmenu_Text) 1166 SectionSetText ${SecShortcutDesktop} $(SecShortcutDesktop_Text) 1167 SectionSetText ${SecSetConfig} $(SecSetConfig_Text) 1168 1169 ;# Look for config dir ("%APPDATA%\opencpn) and the several config files 1170 Call Check_Config_Exists 1171 1172 ${If} $CONFIG_EXISTS != 1 1173 ${OrIf} $CONFIG_EMPTY == 1 1174 Call Hide_SecGrpResetConfig 1175 IntOp $0 ${SF_SELECTED} | ${SF_BOLD} 1176 SectionSetFlags ${SecSetConfig} $0 1177 StrCpy $SetConfig 1 1178 ${EndIf} 1179 1180 SetShellVarContext all ;# switch SetShellVarContext back to ALL 1181FunctionEnd 1182 1183;-------------------------------- 1184;# onSelChange 1185;Var ConfigSetLang 1186;Var ConfigSetChartDir 1187;Var SetConfig 1188Function .onSelChange 1189 ;# Check if all available Sections in SecGrpResetConfig are selected => set SecGrpResetConfig to selected instead of partially selected 1190 Push $0 1191 Push $1 1192 Push $2 1193 Push $3 1194 Push $R0 1195 Push $R1 1196 StrCpy $0 ${SecGrpResetConfig} 1197 StrCpy $1 0 1198 StrCpy $2 0 1199 ${Do} 1200 IntOp $0 $0 + 1 1201 ${If} ${SectionIsSectionGroupEnd} $0 1202 Goto end 1203 ${EndIf} 1204 SectionGetText $0 $R0 1205 ${If} $R0 != "" 1206 ${AndIf} ${SectionIsSelected} $0 1207 Goto found_selected 1208 ${ElseIf} $R0 != "" 1209 ${AndIfNot} ${SectionIsSelected} $0 1210 Goto found_unselected 1211 ${EndIf} 1212 ${Loop} 1213 1214 found_selected: 1215 StrCpy $0 ${SecGrpResetConfig} 1216 ${Do} 1217 IntOp $0 $0 + 1 1218 ${If} ${SectionIsSectionGroupEnd} $0 1219 Goto end 1220 ${EndIf} 1221 SectionGetText $0 $R0 1222 ${If} $R0 == "" 1223 ${AndIfNot} ${SectionIsSelected} $0 1224 SectionSetFlags $0 ${SF_SELECTED} 1225 ${EndIf} 1226 ${Loop} 1227 1228 found_unselected: 1229 StrCpy $0 ${SecGrpResetConfig} 1230 ${Do} 1231 IntOp $0 $0 + 1 1232 ${If} ${SectionIsSectionGroupEnd} $0 1233 Goto end 1234 ${EndIf} 1235 SectionGetText $0 $R0 1236 ${If} $R0 == "" 1237 ${AndIf} ${SectionIsSelected} $0 1238 !insertmacro ClearSectionFlag $0 ${SF_SELECTED} 1239 ${EndIf} 1240 ${Loop} 1241 1242 end: 1243 SectionGetText ${SecDeleteConfigFile} $R1 1244 ${If} $R1 != "" 1245 ${IfNot} ${SectionIsReadOnly} ${SecSetConfig} 1246 ${AndIfNot} ${SectionIsSelected} ${SecSetConfig} 1247 ${AndIf} $SetConfig == 1 1248 StrCpy $SetConfig 0 1249 ${EndIf} 1250 1251 ${IfNot} ${SectionIsSelected} ${SecDeleteConfigFile} 1252 ${AndIf} ${SectionIsSelected} ${SecSetConfig} 1253 !insertmacro ClearSectionFlag ${SecSetConfig} ${SF_SELECTED} 1254 IntOp $0 ${SF_RO} | ${SF_BOLD} 1255 SectionSetFlags ${SecSetConfig} $0 1256 ;SectionSetFlags ${SecSetConfig} ${SF_RO} 1257 StrCpy $SetConfig 1 1258 ${ElseIfNot} ${SectionIsSelected} ${SecDeleteConfigFile} 1259 ${AndIfNot} ${SectionIsSelected} ${SecSetConfig} 1260 IntOp $0 ${SF_RO} | ${SF_BOLD} 1261 SectionSetFlags ${SecSetConfig} $0 1262 ;SectionSetFlags ${SecSetConfig} ${SF_RO} 1263 StrCpy $SetConfig 0 1264 ${ElseIf} ${SectionIsSelected} ${SecDeleteConfigFile} 1265 ${AndIfNot} ${SectionIsSelected} ${SecSetConfig} 1266 ${AndIf} $SetConfig == 1 1267 !insertmacro ClearSectionFlag ${SecSetConfig} ${SF_RO} 1268 IntOp $0 ${SF_SELECTED} | ${SF_BOLD} 1269 SectionSetFlags ${SecSetConfig} $0 1270 ;SectionSetFlags ${SecSetConfig} ${SF_SELECTED} 1271 ${ElseIf} ${SectionIsSelected} ${SecDeleteConfigFile} 1272 ${AndIf} $SetConfig == 0 1273 !insertmacro ClearSectionFlag ${SecSetConfig} ${SF_RO} 1274 StrCpy $SetConfig 0 1275 ${EndIf} 1276 ${EndIf} 1277 1278 Pop $R1 1279 Pop $R0 1280 Pop $3 1281 Pop $2 1282 Pop $1 1283 Pop $0 1284FunctionEnd 1285 1286 1287Function .OnInstFailed 1288 Call InstallerEnd 1289FunctionEnd 1290 1291 1292Function .OnInstSuccess 1293 Call InstallerEnd 1294FunctionEnd 1295 1296 1297Function .onGUIEnd 1298 Call InstallerEnd 1299FunctionEnd 1300 1301 1302Function InstallerEnd 1303 ;# Delete all temporary files created during the installation 1304 Delete "$TEMP\opencpn_*.tmp" 1305 ${If} $EnumHKU_counter > 0 1306 ${ForEach} $1 $EnumHKU_counter 0 - 1 1307 System::Call "advapi32::RegUnLoadKeyW(i ${HKEY_USERS}, t '$key_$1')" 1308 ${Next} 1309 ${Endif} 1310FunctionEnd 1311 1312;-------------------------------- 1313;################################################################################################## 1314;# Installer Page Functions # 1315;################################################################################################## 1316;# Page_License_Leave 1317 Function Page_License_Leave 1318 FindWindow $mui.ComponentsPage "#32770" "" $HWNDPARENT 1319 System::Call "*(i 0, i 0, i 4, i 8) i .r1" 1320 System::Call "User32::MapDialogRect(i $mui.ComponentsPage, i r1) i .r2" 1321 System::Call "*$1(i .r2, i.r3, i.r4, i.r5)" 1322 System::Free $1 1323 StrCpy $BU_X $4 1324 StrCpy $BU_Y $5 1325 FunctionEnd 1326 1327;-------------------------------- 1328;# Page_CleanUp 1329 Var Label_CleanUp 1330 Var Label_FullScan_CleanUp 1331 Var GroupBox_CleanUp 1332 Var ListBox_CleanUp 1333 Var Button_FullScan_CleanUp 1334 Var Button_UnselectAll_CleanUp 1335 Var Button_SelectAll_CleanUp 1336 Var Button_Uninstall_Selected_CleanUp 1337 Var Banner_Handle 1338 Var MSG_Box_Uninstall_Shown 1339 Function Page_CleanUp 1340 ${If} $Skip_Page_CleanUp == 1 1341 Abort 1342 ${EndIf} 1343 1344 !ifndef PBS_MARQUEE 1345 !define PBS_MARQUEE 0x08 1346 !endif 1347 !ifndef PBM_SETMARQUEE 1348 !define PBM_SETMARQUEE 0x040A 1349 !endif 1350 !ifndef GWL_STYLE 1351 !define GWL_STYLE -16 1352 !endif 1353 1354 ${IfNot} $MSG_Box_Uninstall_Shown == 1 1355 MessageBox MB_YESNO|MB_ICONQUESTION "$(Msg_Uninstall_Old_Versions)" IDYES cont IDNO skip 1356 ${Else} 1357 Goto cont 1358 ${EndIf} 1359 1360 skip: 1361 Abort 1362 1363 cont: 1364 StrCpy $MSG_Box_Uninstall_Shown 1 1365 !insertmacro MUI_HEADER_TEXT "$(Page_CleanUp_Title)" "$(Page_CleanUp_Subtitle)" 1366 1367 nsDialogs::Create /NOUNLOAD 1018 1368 Pop $0 1369 ${If} $0 == error 1370 Abort 1371 ${EndIf} 1372 1373 ${NSD_CreateLabel} 0 0 200u 16u "$(LAB_FullScan_CleanUp)" 1374 Pop $Label_FullScan_CleanUp 1375 1376 ${NSD_CreateButton} 220u 0 70u 15u "$(BT_FullScan_CleanUp)" 1377 Pop $Button_FullScan_CleanUp 1378 GetFunctionAddress $0 Button_FullScan_CleanUp_Click 1379 nsDialogs::OnClick /NOUNLOAD $Button_FullScan_CleanUp $0 1380 1381 ${NSD_CreateLabel} 0 22u 100% 24u "$(Label_CleanUp_Text)" 1382 Pop $Label_CleanUp 1383 1384 ${NSD_CreateGroupBox} 0 55u 100% 85u "$(Install_Location_Default)" 1385 Pop $GroupBox_CleanUp 1386 1387 !define __NSD_ListBoxMultiselect_CLASS LISTBOX 1388 !define __NSD_ListBoxMultiselect_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LBS_DISABLENOSCROLL}|${LBS_HASSTRINGS}|${LBS_NOINTEGRALHEIGHT}|${LBS_NOTIFY}|${LBS_MULTIPLESEL} 1389 !define __NSD_ListBoxMultiselect_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE} 1390 !insertmacro __NSD_DefineControl ListBoxMultiselect 1391 ${NSD_CreateListboxMultiselect} 10u 70u 200u 65u "$(LB_CleanUp)" 1392 Pop $ListBox_CleanUp 1393 GetFunctionAddress $0 ListBox_CleanUp_Change 1394 nsDialogs::OnChange /NOUNLOAD $ListBox_CleanUp $0 1395 1396 ${NSD_CreateButton} 220u 70u 70u 15u "$(BT_UnselectAll_CleanUp)" 1397 Pop $Button_UnselectAll_CleanUp 1398 GetFunctionAddress $0 Button_UnselectAll_CleanUp_Click 1399 nsDialogs::OnClick /NOUNLOAD $Button_UnselectAll_CleanUp $0 1400 1401 ${NSD_CreateButton} 220u 100u 70u 15u "$(BT_SelectAll_CleanUp)" 1402 Pop $Button_SelectAll_CleanUp 1403 GetFunctionAddress $0 Button_SelectAll_CleanUp_Click 1404 nsDialogs::OnClick /NOUNLOAD $Button_SelectAll_CleanUp $0 1405 1406 ${NSD_CreateButton} 220u 120u 70u 15u "$(BT_Uninstall_Selected_CleanUp)" 1407 Pop $Button_Uninstall_Selected_CleanUp 1408 GetFunctionAddress $0 Button_Uninstall_Selected_CleanUp_Click 1409 nsDialogs::OnClick /NOUNLOAD $Button_Uninstall_Selected_CleanUp $0 1410 1411 1412 ;# First check if HDD scan was already done 1413 ${If} ${FileExists} "$TEMP\opencpn_hdd_full_scan.tmp" 1414 EnableWindow $Button_FullScan_CleanUp 0 1415 EnableWindow $Label_FullScan_CleanUp 0 1416 SendMessage $GroupBox_CleanUp ${WM_SETTEXT} 0 "STR:$(Install_Location_HDD_Scan)" 1417 ClearErrors 1418 FileOpen $R0 "$TEMP\opencpn_hdd_full_scan.tmp" r 1419 IfErrors done1 1420 ${Do} 1421 FileReadUTF16LE $R0 $R1 1422 ${If} $R1 == "" 1423 Goto done1 1424 ${Else} 1425 ${TrimNewLines} $R1 $R1 1426 SendMessage $ListBox_CleanUp ${LB_ADDSTRING} 0 "STR:$R1" 1427 ${EndIf} 1428 ${Loop} 1429 done1: 1430 FileClose $R0 1431 ;# if not get values from LM_VERSION and opencpn_old_installs.tmp file 1432 ${Else} 1433 ${IfNot} ${FileExists} "$TEMP\opencpn_hdd_quick_scan.tmp" 1434 ;# Scan the default locations for program installations on a per-user and all-users basis 1435 Banner::show /NOUNLOAD /set 76 "$(Search_old_installations)" 1436 Banner::getWindow /NOUNLOAD 1437 Pop $Banner_Handle 1438 ShowWindow $Banner_Handle ${SW_HIDE} 1439 ${NSD_AddExStyle} $Banner_Handle ${WS_EX_APPWINDOW} 1440 ShowWindow $Banner_Handle ${SW_SHOW} 1441 GetDlgItem $2 $Banner_Handle 1030 1442 SendMessage $2 ${WM_SETTEXT} 0 "STR:$(text_please_wait_1)" 1443 1444 ; Get progress bar handle. 1445 GetDlgItem $Marquee_Handle $Banner_Handle 1004 1446 1447 ; Set PBS_MARQUEE style for the progress bar control. 1448 System::Call "user32::GetWindowLong(i $Marquee_Handle, i ${GWL_STYLE}) i .r1" 1449 System::Call "user32::SetWindowLong(i $Marquee_Handle, i ${GWL_STYLE}, i $1|${PBS_MARQUEE})" 1450 1451 ; Send PBM_SETMARQUEE message to start the marquee. 1452 ; lParam is time in milliseconds between marquee animation updates. 1453 SendMessage $Marquee_Handle ${PBM_SETMARQUEE} 1 50 1454 1455 System::Call "User32::SetWindowPos(i $Banner_Handle, i -1, i 0, i 0, i 0, i 0, i 83)" 1456 1457 HideWindow 1458 1459 Call Quick_Scan_Old_Versions 1460 1461 ShowWindow $HWNDPARENT ${SW_SHOW} 1462 BringToFront 1463 SendMessage $Marquee_Handle ${PBM_SETMARQUEE} 0 0 1464 System::Call "user32::SetWindowLong(i $Marquee_Handle, i ${GWL_STYLE}, i $1)" 1465 Banner::destroy 1466 ${EndIf} 1467 1468 ClearErrors 1469 FileOpen $R0 "$TEMP\opencpn_hdd_quick_scan.tmp" r 1470 IfErrors done2 1471 ${Do} 1472 FileReadUTF16LE $R0 $R1 1473 ${If} $R1 == "" 1474 Goto done2 1475 ${Else} 1476 ${TrimNewLines} $R1 $R1 1477 SendMessage $ListBox_CleanUp ${LB_ADDSTRING} 0 "STR:$R1" 1478 ${EndIf} 1479 ${Loop} 1480 1481 done2: 1482 FileClose $R0 1483 ${EndIf} 1484 /* 1485 ;# Pre-select all listbox-items 1486 ${NSD_LB_GetCount} $ListBox_CleanUp $1 1487 IntOp $1 $1 - 1 1488 SendMessage $ListBox_CleanUp ${LB_SELITEMRANGEEX} 0 $1 1489 */ 1490 Call ListBox_CleanUp_Change 1491 1492 nsDialogs::Show 1493 FunctionEnd 1494 1495 Function Button_FullScan_CleanUp_Click 1496 SendMessage $ListBox_CleanUp ${LB_RESETCONTENT} 0 0 1497 1498 Banner::show /NOUNLOAD /set 76 "$(Scanning_HDD)" 1499 Banner::getWindow /NOUNLOAD 1500 Pop $Banner_Handle 1501 ShowWindow $Banner_Handle ${SW_HIDE} 1502 SendMessage $Banner_Handle ${WM_SETTEXT} 0 "STR:$(OCPN_Scanning_HDD)" 1503 ${NSD_AddExStyle} $Banner_Handle ${WS_EX_APPWINDOW} 1504 ShowWindow $Banner_Handle ${SW_SHOW} 1505 GetDlgItem $2 $Banner_Handle 1030 1506 SendMessage $2 ${WM_SETTEXT} 0 "STR:$(text_please_wait_1)" 1507 1508 ; Get progress bar handle. 1509 GetDlgItem $Marquee_Handle $Banner_Handle 1004 1510 1511 ; Set PBS_MARQUEE style for the progress bar control. 1512 System::Call "user32::GetWindowLong(i $Marquee_Handle, i ${GWL_STYLE}) i .r1" 1513 System::Call "user32::SetWindowLong(i $Marquee_Handle, i ${GWL_STYLE}, i $1|${PBS_MARQUEE})" 1514 1515 ; Send PBM_SETMARQUEE message to start the marquee. 1516 ; lParam is time in milliseconds between marquee animation updates. 1517 SendMessage $Marquee_Handle ${PBM_SETMARQUEE} 1 50 1518 1519 System::Call "User32::SetWindowPos(i $Banner_Handle, i -1, i 0, i 0, i 0, i 0, i 83)" 1520 1521 HideWindow 1522 1523 Call Full_Scan_Old_Versions 1524 1525 ${If} ${FileExists} "$TEMP\opencpn_hdd_full_scan.tmp" 1526 Delete "$TEMP\opencpn_hdd_quick_scan.tmp" 1527 ${EndIf} 1528 1529 ;# If install locations were found compare with Registry keys 1530 ${If} $counter_tmp > 0 1531 ${If} $LM_VERSION_INST != "" 1532 ClearErrors 1533 FileOpen $R0 "$TEMP\opencpn_hdd_full_scan.tmp" r 1534 IfErrors done1 1535 ${Do} 1536 FileReadUTF16LE $R0 $R1 1537 ${If} $R1 == "" 1538 Goto done1 1539 ${Else} 1540 ${TrimNewLines} $R1 $R1 1541 StrCmp $R1 $R2 done1 1542 ${EndIf} 1543 ${Loop} 1544 ;# Path from Registry key wasn't found => delete RegKey 1545 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1" 1546 StrCpy $LM_VERSION_INST "" 1547 1548 done1: 1549 FileClose $R0 1550 ${EndIf} 1551 1552 ${If} ${FileExists} "$TEMP\opencpn_old_installs.tmp" 1553 ;# Clear the stack 1554 ClearErrors 1555 ${Do} 1556 Pop $0 1557 IfErrors empty 1558 ${Loop} 1559 empty: 1560 1561 ClearErrors 1562 FileOpen $R0 "$TEMP\opencpn_old_installs.tmp" r 1563 1564 IfErrors done3 1565 ${Do} 1566 FileReadUTF16LE $R0 $R3 1567 FileReadUTF16LE $R0 $R2 1568 ${If} $R3 == "" 1569 Goto done3 1570 ${Else} 1571 ${TrimNewLines} $R3 $R3 1572 ${TrimNewLines} $R2 $R2 1573 FileReadUTF16LE $R0 $R1 1574 ${TrimNewLines} $R1 $R1 1575 ClearErrors 1576 FileOpen $0 "$TEMP\opencpn_hdd_full_scan.tmp" r 1577 IfErrors next 1578 ${Do} 1579 FileReadUTF16LE $0 $1 1580 ${If} $1 == "" 1581 Goto next 1582 ${Else} 1583 ${TrimNewLines} $1 $1 1584 StrCmp $1 $R1 done2 1585 ${EndIf} 1586 ${Loop} 1587 ;# Path from Registry key wasn't found => delete RegKey 1588 DeleteRegKey HKU $R3 1589 Goto next 1590 1591 done2: 1592 Push $R1 1593 Push $R2 1594 Push $R3 1595 next: 1596 FileClose $0 1597 ${EndIf} 1598 ${Loop} 1599 done3: 1600 FileClose $R0 1601 1602 ClearErrors 1603 FileOpen $R0 "$TEMP\opencpn_old_installs.tmp" w 1604 IfErrors done4 1605 ${Do} 1606 Pop $R1 1607 IfErrors done4 1608 FileWriteUTF16LE $R0 $R1 1609 FileWriteUTF16LE $R0 "$\r$\n" 1610 ${Loop} 1611 done4: 1612 FileClose $R0 1613 ${EndIf} 1614 ${EndIf} 1615 1616 EnableWindow $Button_FullScan_CleanUp 0 ;# Disable the Scan HDD button after scan was done 1617 EnableWindow $Label_FullScan_CleanUp 0 ;# Disable the Scan HDD label after scan was done 1618 SendMessage $GroupBox_CleanUp ${WM_SETTEXT} 0 "STR:$(Install_Location_HDD_Scan)" 1619 1620 ShowWindow $HWNDPARENT ${SW_SHOW} 1621 BringToFront 1622 1623 ; Stop the marquee and set the old styles back for the progress bar control. 1624 SendMessage $Marquee_Handle ${PBM_SETMARQUEE} 0 0 1625 System::Call "user32::SetWindowLong(i $Marquee_Handle, i ${GWL_STYLE}, i $1)" 1626 1627 Banner::destroy 1628 FunctionEnd 1629 1630 Function Button_UnselectAll_CleanUp_Click 1631 SendMessage $ListBox_CleanUp ${LB_SETSEL} FALSE -1 1632 Call ListBox_CleanUp_Change 1633 FunctionEnd 1634 1635 Function Button_SelectAll_CleanUp_Click 1636 ${NSD_LB_GetCount} $ListBox_CleanUp $1 1637 IntOp $1 $1 - 1 1638 ${If} $1 == 0 1639 IntOp $1 $1 + 1 1640 ${EndIf} 1641 SendMessage $ListBox_CleanUp ${LB_SELITEMRANGEEX} 0 $1 1642 Call ListBox_CleanUp_Change 1643 FunctionEnd 1644 1645 Function ListBox_CleanUp_Change 1646 SendMessage $ListBox_CleanUp ${LB_GETSELCOUNT} 0 0 $1 1647 ${NSD_LB_GetCount} $ListBox_CleanUp $2 1648 ${If} $2 > 0 1649 ${If} $1 == 0 1650 EnableWindow $Button_Uninstall_Selected_CleanUp 0 1651 EnableWindow $Button_UnselectAll_CleanUp 0 1652 EnableWindow $Button_SelectAll_CleanUp 1 1653 ${ElseIf} $1 > 0 1654 ${AndIf} $1 == $2 1655 EnableWindow $Button_Uninstall_Selected_CleanUp 1 1656 EnableWindow $Button_UnselectAll_CleanUp 1 1657 EnableWindow $Button_SelectAll_CleanUp 0 1658 ${Else} 1659 EnableWindow $Button_Uninstall_Selected_CleanUp 1 1660 EnableWindow $Button_UnselectAll_CleanUp 1 1661 EnableWindow $Button_SelectAll_CleanUp 1 1662 ${EndIf} 1663 ${Else} 1664 EnableWindow $Button_Uninstall_Selected_CleanUp 0 1665 EnableWindow $Button_UnselectAll_CleanUp 0 1666 EnableWindow $Button_SelectAll_CleanUp 0 1667 ${EndIf} 1668 FunctionEnd 1669 1670 Var Uninstall_Path_Tmp 1671 Function Button_Uninstall_Selected_CleanUp_Click 1672 EnableWindow $Button_Uninstall_Selected_CleanUp 0 1673 SendMessage $ListBox_CleanUp ${LB_GETSELCOUNT} 0 0 $1 1674 ${NSD_LB_GetCount} $ListBox_CleanUp $2 1675 ClearErrors 1676 FileOpen $R0 "$TEMP\opencpn_uninstall.tmp" w 1677 IfErrors done 1678 IntOp $2 $2 - 1 1679 ${ForEach} $3 $2 0 - 1 1680 SendMessage $ListBox_CleanUp ${LB_GETSEL} $3 0 $4 1681 ${If} $4 > 0 1682 System::Call "User32::SendMessage(i $ListBox_CleanUp, i ${LB_GETTEXT}, i $3, t .r5)" 1683 FileWriteUTF16LE $R0 "$5" 1684 FileWriteUTF16LE $R0 "$\r$\n" 1685 SendMessage $ListBox_CleanUp ${LB_DELETESTRING} $3 0 1686 ${EndIf} 1687 ${Next} 1688 done: 1689 FileClose $R0 1690 1691 Call ListBox_CleanUp_Change 1692 1693 StrCpy $R8 "" 1694 StrCpy $R7 "" 1695 StrCpy $R6 "" 1696 StrCpy $R5 "" 1697 ${If} ${FileExists} "$TEMP\opencpn_uninstall.tmp" 1698 ${If} ${FileExists} "$TEMP\opencpn_hdd_full_scan.tmp" 1699 StrCpy $R8 "opencpn_hdd_full_scan.tmp" 1700 ${ElseIf} ${FileExists} "$TEMP\opencpn_hdd_quick_scan.tmp" 1701 StrCpy $R8 "opencpn_hdd_quick_scan.tmp" 1702 ${EndIf} 1703 1704 ${If} ${FileExists} "$TEMP\opencpn_old_installs.tmp" 1705 StrCpy $R7 1 1706 ${EndIf} 1707 1708 ${If} ${FileExists} "$TEMP\opencpn_old_uninstall_regkeys.tmp" 1709 StrCpy $R6 1 1710 ${EndIf} 1711 1712 ${If} ${FileExists} "$TEMP\opencpn_appdata.tmp" 1713 StrCpy $R5 1 1714 ${EndIf} 1715 1716 ClearErrors 1717 FileOpen $R4 "$TEMP\opencpn_uninstall.tmp" r 1718 IfErrors end 1719 loop: 1720 ClearErrors 1721 FileReadUTF16LE $R4 $0 1722 IfErrors end 1723 StrCmp $0 "" loop 1724 StrCmp $0 "$\r$\n" loop 1725 1726 ${TrimNewLines} $0 $0 1727 StrCpy $Uninstall_Path_Tmp $0 1728 1729 ;# Delete installation directory 1730 ClearErrors 1731 Call Delete_Installation_Dir 1732 IfErrors 0 +2 1733 MessageBox MB_OK|MB_ICONEXCLAMATION "Error RMDir: $0" ;#ON ERROR 1734 1735 ;# If deleted installation was the one in the HKLM ...\OpenCPN_is1 subkey => delete RegKey 1736 ${If} $LM_VERSION_INST != "" 1737 StrCmp $0 $LM_VERSION_INST 0 cont 1738 ClearErrors 1739 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1" 1740 IfErrors 0 +2 1741 MessageBox MB_OK|MB_ICONEXCLAMATION "Error DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1" ;#ON ERROR 1742 StrCpy $LM_VERSION "" 1743 StrCpy $LM_VERSION_INST "" 1744 StrCpy $LM_VERSION_UNINST "" 1745 ${EndIf} 1746 1747 cont: 1748 ;# Delete Start Menu shortcuts 1749 Push $Uninstall_Path_Tmp 1750 Call Delete_Start_Menu_Shortcuts 1751 1752 ;# Delete Desktop shortcuts 1753 Push $Uninstall_Path_Tmp 1754 Call Delete_Desktop_Shortcuts 1755 1756 ;# Delete RegKeys in HKU Software\opencpn.org\... 1757 ${If} $R7 == 1 1758 Call Update_Old_Installs 1759 ${EndIf} 1760 1761 ;# Delete RegKeys in HKU Software\...\Uninstall\OpenCPN 1762 ${If} $R6 == 1 1763 Call Update_Old_Uninstalls 1764 ${EndIf} 1765 1766 ;# Delete %APPDATA\opencpn folder 1767 ${If} $R5 == 1 1768 Call Update_Appdata 1769 ${EndIf} 1770 1771 ${IfNot} $R8 == "" 1772 Call Update_HDD_Scan 1773 ${EndIf} 1774 1775 Goto loop 1776 end: 1777 FileClose $R4 1778 Delete "$TEMP\opencpn_uninstall.tmp" 1779 StrCpy $Uninstall_Path_Tmp "" 1780 ${EndIf} 1781 1782 ${NSD_LB_GetCount} $ListBox_CleanUp $2 1783 ${If} $2 == 0 ;# listbox is empty - all were uninstalled 1784 StrCpy $Skip_Page_CleanUp 1 1785 GetDlgItem $0 $HWNDPARENT 1 1786 SendMessage $0 ${BM_CLICK} 0 0 1787 ${EndIf} 1788 FunctionEnd 1789 1790 Function Update_HDD_Scan 1791 Push $0 1792 Push $1 1793 Push $2 1794 Push $3 1795 Push $4 1796 Push $R0 1797 Push $R8 1798 ClearErrors 1799 FileOpen $0 "$TEMP\$R8" r ;# open target file for reading 1800 GetTempFileName $R0 ;# get new temp file name 1801 FileOpen $1 $R0 w ;# open temp file for writing 1802 IfErrors end 1803 loop: 1804 FileReadUTF16LE $0 $2 ;# read line from target file 1805 IfErrors done ;# check if end of file reached 1806 ${TrimNewLines} $2 $2 1807 StrCmp $2 "$Uninstall_Path_Tmp" +2 ;# compare line with search string with CR/LF 1808 FileWriteUTF16LE $1 "$2$\r$\n" ;# write line to temp file 1809 Goto loop 1810 done: 1811 FileClose $0 ;# close target file 1812 FileClose $1 ;# close temp file 1813 Delete "$TEMP\$R8" ;# delete target file 1814 CopyFiles /SILENT $R0 "$TEMP\$R8" ;# copy temp file to target file 1815 Delete $R0 ;# delete temp file 1816 end: 1817 Pop $R8 1818 Pop $R0 1819 Pop $4 1820 Pop $3 1821 Pop $2 1822 Pop $1 1823 Pop $0 1824 FunctionEnd 1825 1826 Function Update_Old_Installs 1827 Push $0 1828 Push $1 1829 Push $2 1830 Push $3 1831 Push $4 1832 Push $R0 1833 Push $R1 1834 ClearErrors 1835 FileOpen $0 "$TEMP\opencpn_old_installs.tmp" r ;# open target file for reading 1836 GetTempFileName $R0 ;# get new temp file name 1837 FileOpen $1 $R0 w ;# open temp file for writing 1838 IfErrors end 1839 loop: 1840 FileReadUTF16LE $0 $4 ;# read line from target file 1841 FileReadUTF16LE $0 $3 ;# read line from target file 1842 FileReadUTF16LE $0 $2 ;# read line from target file 1843 IfErrors done ;# check if end of file reached 1844 ${TrimNewLines} $2 $2 1845 StrCmp $2 "$Uninstall_Path_Tmp" +5 ;# compare line with search string with CR/LF 1846 FileWriteUTF16LE $1 $4 ;# write line to temp file 1847 FileWriteUTF16LE $1 $3 ;# write line to temp file 1848 FileWriteUTF16LE $1 "$2$\r$\n" ;# write line to temp file 1849 Goto loop 1850 ${TrimNewLines} $4 $4 1851 DeleteRegKey HKU "$4" 1852 ${WordFind} "$4" "\" "-2{*" $4 1853 DeleteRegKey /ifempty HKU "$4" 1854 ClearErrors 1855 Goto loop 1856 done: 1857 FileClose $0 ;# close target file 1858 FileClose $1 ;# close temp file 1859 Delete "$TEMP\opencpn_old_installs.tmp" ;# delete target file 1860 CopyFiles /SILENT $R0 "$TEMP\opencpn_old_installs.tmp" ;# copy temp file to target file 1861 Delete $R0 ;# delete temp file 1862 end: 1863 Pop $R1 1864 Pop $R0 1865 Pop $4 1866 Pop $3 1867 Pop $2 1868 Pop $1 1869 Pop $0 1870 FunctionEnd 1871 1872 Function Update_Old_Uninstalls 1873 Push $0 1874 Push $1 1875 Push $2 1876 Push $3 1877 Push $4 1878 Push $R0 1879 Push $R1 1880 ClearErrors 1881 FileOpen $0 "$TEMP\opencpn_old_uninstall_regkeys.tmp" r ;# open target file for reading 1882 GetTempFileName $R0 ;# get new temp file name 1883 FileOpen $1 $R0 w ;# open temp file for writing 1884 IfErrors end 1885 loop: 1886 FileReadUTF16LE $0 $4 ;# read line from target file 1887 FileReadUTF16LE $0 $3 ;# read line from target file 1888 FileReadUTF16LE $0 $2 ;# read line from target file 1889 IfErrors done ;# check if end of file reached 1890 ${TrimNewLines} $2 $2 1891 StrCmp $2 "$Uninstall_Path_Tmp" +5 ;# compare line with search string with CR/LF 1892 FileWriteUTF16LE $1 $4 ;# write line to temp file 1893 FileWriteUTF16LE $1 $3 ;# write line to temp file 1894 FileWriteUTF16LE $1 "$2$\r$\n" ;# write line to temp file 1895 Goto loop 1896 ${TrimNewLines} $3 $3 1897 DeleteRegKey HKU "$3" 1898 ClearErrors 1899 Goto loop 1900 done: 1901 FileClose $0 ;# close target file 1902 FileClose $1 ;# close temp file 1903 Delete "$TEMP\opencpn_old_uninstall_regkeys.tmp" ;# delete target file 1904 CopyFiles /SILENT $R0 "$TEMP\opencpn_old_uninstall_regkeys.tmp" ;# copy temp file to target file 1905 Delete $R0 ;# delete temp file 1906 end: 1907 Pop $R1 1908 Pop $R0 1909 Pop $4 1910 Pop $3 1911 Pop $2 1912 Pop $1 1913 Pop $0 1914 FunctionEnd 1915 1916 Function Update_Appdata 1917 Push $0 1918 Push $1 1919 Push $2 1920 Push $3 1921 Push $4 1922 Push $R0 1923 Push $R1 1924 ClearErrors 1925 FileOpen $0 "$TEMP\opencpn_appdata.tmp" r ;# open target file for reading 1926 GetTempFileName $R0 ;# get new temp file name 1927 FileOpen $1 $R0 w ;# open temp file for writing 1928 IfErrors end 1929 loop: 1930 FileReadUTF16LE $0 $4 ;# read line from target file 1931 FileReadUTF16LE $0 $3 ;# read line from target file 1932 FileReadUTF16LE $0 $2 ;# read line from target file 1933 IfErrors done ;# check if end of file reached 1934 ${TrimNewLines} $2 $2 1935 StrCmp $2 "$Uninstall_Path_Tmp" +5 ;# compare line with search string with CR/LF 1936 FileWriteUTF16LE $1 $4 ;# write line to temp file 1937 FileWriteUTF16LE $1 $3 ;# write line to temp file 1938 FileWriteUTF16LE $1 "$2$\r$\n" ;# write line to temp file 1939 Goto loop 1940 ${TrimNewLines} $3 $3 1941 RMDir /r "$3\opencpn" 1942 ClearErrors 1943 Goto loop 1944 done: 1945 FileClose $0 ;# close target file 1946 FileClose $1 ;# close temp file 1947 Delete "$TEMP\opencpn_appdata.tmp" ;# delete target file 1948 CopyFiles /SILENT $R0 "$TEMP\opencpn_appdata.tmp" ;# copy temp file to target file 1949 Delete $R0 ;# delete temp file 1950 end: 1951 Pop $R1 1952 Pop $R0 1953 Pop $4 1954 Pop $3 1955 Pop $2 1956 Pop $1 1957 Pop $0 1958 FunctionEnd 1959 1960;-------------------------------- 1961;# Page_CleanUp_Leave 1962 Function Page_CleanUp_Leave 1963 ${NSD_LB_GetCount} $ListBox_CleanUp $2 1964 ${If} $2 > 0 ;# listbox is not empty - not all old versions were uninstalled 1965 MessageBox MB_YESNO|MB_ICONQUESTION "$(Msg_Not_All_Old_Uninstalled)" IDYES leaving 1966 Abort 1967 ${EndIf} 1968 leaving: 1969 SendMessage $ListBox_CleanUp ${LB_RESETCONTENT} 0 0 1970 FunctionEnd 1971 1972;-------------------------------- 1973;# Page_TypeInst 1974/* Var Label_TypeInst_Reinstall 1975 Var RB_Reinstall 1976 Var Label_TypeInst_Upgrade 1977 Var RB_Upgrade 1978 Var Label_TypeInst_Downgrade 1979 Var RB_Downgrade 1980 Var Label_TypeInst_Parallel 1981 Var GroupBox_TypeInst 1982 Var RB_Parallel 1983 Var TI_REINSTALL 1984 Var TI_UPGRADE 1985 Var TI_DOWNGRADE 1986 Var TI_PARALLEL 1987 Var GroupBox_Size 1988 Var INSTALL_TYPE 1989 */ 1990 Function Page_TypeInst 1991 ${If} $Skip_Page_TypeInst == 1 1992 Abort 1993 ${EndIf} 1994 ${If} $VERSION_EXISTS == 1 1995 !insertmacro MUI_HEADER_TEXT $(Page_TypeInst_Title_Exists) $(Page_TypeInst_Subtitle_Exists) 1996 ${ElseIf} $MULTIPLE_INSTALLS == 1 1997 !insertmacro MUI_HEADER_TEXT $(Page_TypeInst_Title_1) $(Page_TypeInst_Subtitle_1) 1998 ${ElseIf} $MULTIPLE_INSTALLS > 1 1999 !insertmacro MUI_HEADER_TEXT $(Page_TypeInst_Title) $(Page_TypeInst_Subtitle) 2000 ${EndIf} 2001 2002 nsDialogs::Create /NOUNLOAD 1018 2003 Pop $0 2004 2005 ${If} $0 == error 2006 Abort 2007 ${EndIf} 2008 2009 ;Case 1: same version already installed => Option 1: Reinstall 2010 ${If} $VERSION_EXISTS == 1 2011 ${NSD_CreateLabel} 0 0 100% 40u "$(Label_TypeInst_Reinstall_Text)" 2012 Pop $Label_TypeInst_Reinstall 2013 2014 ${NSD_CreateRadioButton} 10u 65u 100% 10u "$(RB_Reinstall_TypeInst_Text)" 2015 Pop $RB_Reinstall 2016 ${NSD_AddStyle} $RB_Reinstall ${WS_GROUP} 2017 ${NSD_SetState} $RB_Reinstall ${BST_CHECKED} 2018 2019 StrCpy $GroupBox_Size 1 2020 ;Case 2: one older previous installation => Option 1: Upgrade Option 2: Parallel Installation 2021 ${ElseIf} $MULTIPLE_INSTALLS == 1 2022 ${AndIf} $VERSION_NEWER == 1 2023 ${NSD_CreateLabel} 0 0 100% 32u "$(Label_TypeInst_Upgrade_Text)" 2024 Pop $Label_TypeInst_Upgrade 2025 2026 ${NSD_CreateRadioButton} 10u 65u 100% 10u "$(RB_Upgrade_TypeInst_Text)" 2027 Pop $RB_Upgrade 2028 ${NSD_AddStyle} $RB_Upgrade ${WS_GROUP} 2029 ${If} $TI_UPGRADE != "" 2030 ${NSD_SetState} $RB_Upgrade $TI_UPGRADE 2031 ${ElseIf} $TI_UPGRADE == "" 2032 ${AndIf} $TI_PARALLEL == "" 2033 ${NSD_SetState} $RB_Upgrade ${BST_CHECKED} 2034 ${EndIf} 2035 2036 ${NSD_CreateRadioButton} 10u 85u 100% 10u "$(RB_Parallel_TypeInst_Text)" 2037 Pop $RB_Parallel 2038 ${If} $TI_PARALLEL != "" 2039 ${NSD_SetState} $RB_Parallel $TI_PARALLEL 2040 ${EndIf} 2041 2042 StrCpy $GroupBox_Size 2 2043 ;Case 3: one newer previous installation => Option 1: Downgrade Option 2: Parallel Installation 2044 ${ElseIf} $MULTIPLE_INSTALLS == 1 2045 ${AndIf} $VERSION_OLDER == 1 2046 ${NSD_CreateLabel} 0 0 100% 32u "$(Label_TypeInst_Downgrade_Text)" 2047 Pop $Label_TypeInst_Downgrade 2048 2049 ${NSD_CreateRadioButton} 10u 65u 100% 10u "$(RB_Downgrade_TypeInst_Text)" 2050 Pop $RB_Downgrade 2051 ${NSD_AddStyle} $RB_Downgrade ${WS_GROUP} 2052 ${If} $TI_DOWNGRADE != "" 2053 ${NSD_SetState} $RB_Upgrade $TI_DOWNGRADE 2054 ${ElseIf} $TI_DOWNGRADE == "" 2055 ${AndIf} $TI_PARALLEL == "" 2056 ${NSD_SetState} $RB_Downgrade ${BST_CHECKED} 2057 ${EndIf} 2058 2059 ${NSD_CreateRadioButton} 10u 85u 100% 10u "$(RB_Parallel_TypeInst_Text)" 2060 Pop $RB_Parallel 2061 ${If} $TI_PARALLEL != "" 2062 ${NSD_SetState} $RB_Parallel $TI_PARALLEL 2063 ${EndIf} 2064 2065 StrCpy $GroupBox_Size 2 2066 ;Case 4: more than one previous installation => Option 1: Parallel Installation 2067 ${ElseIf} $MULTIPLE_INSTALLS > 1 2068 ${NSD_CreateLabel} 0 0 100% 32u "$(Label_TypeInst_Parallel_Text)" 2069 Pop $Label_TypeInst_Parallel 2070 2071 ${NSD_CreateRadioButton} 10u 65u 100% 10u "$(RB_Parallel_TypeInst_Text)" 2072 Pop $RB_Parallel 2073 ${NSD_AddStyle} $RB_Parallel ${WS_GROUP} 2074 ${NSD_SetState} $RB_Parallel ${BST_CHECKED} 2075 2076 StrCpy $GroupBox_Size 1 2077 ${EndIf} 2078 2079 ${If} $GroupBox_Size == 1 2080 ${NSD_CreateGroupBox} 0 50u 100% 35u "Install Type" 2081 Pop $GroupBox_TypeInst 2082 ${ElseIf} $GroupBox_Size == 2 2083 ${NSD_CreateGroupBox} 0 50u 100% 55u "Install Type" 2084 Pop $GroupBox_TypeInst 2085 ${EndIf} 2086 2087 nsDialogs::Show 2088 FunctionEnd 2089 2090;-------------------------------- 2091;# Page_TypeInst_Leave 2092 Function Page_TypeInst_Leave 2093 ${If} $RB_Reinstall != "" 2094 ${NSD_GetState} $RB_Reinstall $TI_REINSTALL 2095 ${EndIf} 2096 ${If} $RB_Upgrade != "" 2097 ${NSD_GetState} $RB_Upgrade $TI_UPGRADE 2098 ${EndIf} 2099 ${If} $RB_Downgrade != "" 2100 ${NSD_GetState} $RB_Downgrade $TI_DOWNGRADE 2101 ${EndIf} 2102 ${If} $RB_Parallel != "" 2103 ${NSD_GetState} $RB_Parallel $TI_PARALLEL 2104 ${EndIf} 2105 2106 StrCpy $Skip_Page_Directory "" 2107 ${If} $TI_REINSTALL == 1 2108 StrCpy $INSTALL_TYPE 1 2109 ${ElseIf} $TI_UPGRADE == 1 2110 StrCpy $INSTALL_TYPE 2 2111 ${ElseIf} $TI_DOWNGRADE == 1 2112 StrCpy $INSTALL_TYPE 3 2113 ${ElseIf} $TI_PARALLEL == 1 2114 StrCpy $INSTALL_TYPE 4 2115 ${EndIf} 2116 2117 ${If} $INSTALL_TYPE == 1 2118 ${OrIf} $INSTALL_TYPE == 2 2119 ${OrIf} $INSTALL_TYPE == 3 2120 StrCpy $Skip_Page_Directory 1 2121 ReadRegStr $0 HKLM "$Prev_Install_RegKey" "InstallLocation" 2122 StrCpy $INSTDIR $0 2123 ${EndIf} 2124 2125 ; On Upgrade or Downgrade, tentatively trim any Package Version trailer from install location 2126 ${If} $INSTALL_TYPE == 2 2127 ${OrIf} $INSTALL_TYPE == 3 2128 StrCpy $R1 0 2129 Push $INSTDIR 2130 Push "OpenCPN" 2131 Push ">" 2132 Call StrLoc 2133 Pop $0 2134 2135 StrCpy $R1 $INSTDIR $0 2136 StrCpy $R1 "$R1OpenCPN" 2137 StrLen $R2 $INSTDIR 2138 StrLen $R3 $R1 2139 2140 ; If Previous install dir was a parallel, make the upgrade also parallel. 2141 ${If} $R2 > $R3 2142 StrCpy $INSTDIR "$R1 @CPACK_PACKAGE_VERSION@" 2143 ${Else} 2144 StrCpy $INSTDIR $R1 2145 ${Endif} 2146 2147 ${Endif} 2148 2149 ${If} $INSTALL_TYPE == 4 2150 StrCpy $INSTDIR "$PROGRAMFILES\OpenCPN @CPACK_PACKAGE_VERSION@" 2151 ${EndIf} 2152 FunctionEnd 2153 2154;-------------------------------- 2155;# Page_Components_Pre 2156 Function Page_Components_Pre 2157 2158 FunctionEnd 2159 2160;-------------------------------- 2161;# Page_Components_Show 2162 Function Page_Components_Show 2163 ;# change controls size and position on the Components Page 2164 Push $0 2165 Push $1 2166 Push $2 2167 Push $3 2168 Push $4 2169 Push $5 2170 Push $6 2171 Push $7 2172 2173 FindWindow $mui.ComponentsPage "#32770" "" $HWNDPARENT 2174 2175 ;GetDlgItem $mui.ComponentsPage.Text $mui.ComponentsPage 1006 2176 GetDlgItem $mui.ComponentsPage.InstTypesText $mui.ComponentsPage 1021 2177 ShowWindow $mui.ComponentsPage.InstTypesText ${SW_HIDE} 2178 2179 GetDlgItem $mui.ComponentsPage.ComponentsText $mui.ComponentsPage 1022 2180 GetDlgItem $mui.ComponentsPage.InstTypes $mui.ComponentsPage 1017 2181 ShowWindow $mui.ComponentsPage.InstTypes ${SW_HIDE} 2182 2183 GetDlgItem $mui.ComponentsPage.Components $mui.ComponentsPage 1032 2184 GetDlgItem $mui.ComponentsPage.DescriptionTitle $mui.ComponentsPage 1042 2185 GetDlgItem $mui.ComponentsPage.DescriptionText $mui.ComponentsPage 1043 2186 GetDlgItem $mui.ComponentsPage.SpaceRequired $mui.ComponentsPage 1023 2187 ShowWindow $mui.ComponentsPage.SpaceRequired ${SW_HIDE} 2188 2189 Push "198" 2190 Push "40" 2191 Push "100" 2192 Push "100" 2193 Call DU2Pix 2194 System::Call "User32::SetWindowPos(i $mui.ComponentsPage.DescriptionTitle, i 0, i $1, i $2, i $3, i $4, i 64)" ;# 1042 2195 2196 Push "203" 2197 Push "50" 2198 Push "90" 2199 Push "85" 2200 Call DU2Pix 2201 System::Call "User32::SetWindowPos(i $mui.ComponentsPage.DescriptionText, i 0, i $1, i $2, i $3, i $4, i 64)" ;# 1043 2202 2203 Push "0" 2204 Push "25" 2205 Push "300" 2206 Push "15" 2207 Call DU2Pix 2208 System::Call "User32::SetWindowPos(i $mui.ComponentsPage.ComponentsText, i 0, i $1, i $2, i $3, i $4, i 64)" ;# 1022 2209 2210 Push "0" 2211 Push "40" 2212 Push "195" 2213 Push "100" 2214 Call DU2Pix 2215 System::Call "User32::SetWindowPos(i $mui.ComponentsPage.Components, i 0, i $1, i $2, i $3, i $4, i 64)" ;# 1032 2216 2217 Pop $7 2218 Pop $6 2219 Pop $5 2220 Pop $4 2221 Pop $3 2222 Pop $2 2223 Pop $1 2224 Pop $0 2225 FunctionEnd 2226 2227;-------------------------------- 2228;# Page_Components_Leave 2229 Function Page_Components_Leave 2230 ${IfNot} ${SectionIsSelected} ${SecSetConfig} 2231 StrCpy $Skip_Page_SetConfig 1 2232 ${Else} 2233 StrCpy $Skip_Page_SetConfig 0 2234 ${EndIf} 2235 2236 ${IfNot} ${SectionIsSelected} ${SecShortcutStartmenu} 2237 StrCpy $Skip_Page_Startmenu 1 2238 ${Else} 2239 StrCpy $Skip_Page_Startmenu 0 2240 ${EndIf} 2241 FunctionEnd 2242 2243;-------------------------------- 2244;# Page_Directory_Pre 2245 Function Page_Directory_Pre 2246 ${If} $Skip_Page_Directory == 1 2247 Abort 2248 ${EndIf} 2249 FunctionEnd 2250 2251;-------------------------------- 2252;# Page_Directory_Leave 2253 Function Page_Directory_Leave 2254 GetInstDirError $R0 2255 ${If} $R0 > 0 ;# Invalid path entered 2256 MessageBox MB_OK|MB_ICONSTOP "$(Msg_Path_Invalid)" 2257 Abort 2258 ${EndIf} 2259 2260 ${If} $INSTALL_TYPE == 4 2261 ${AndIf} ${FileExists} "$INSTDIR\opencpn.exe" 2262 MessageBox MB_OK|MB_ICONSTOP "$(Msg_Path_Installation_Exists)" 2263 Abort 2264 ${EndIf} 2265 FunctionEnd 2266 2267;-------------------------------- 2268;# Page_Startmenu_Pre 2269 Function Page_Startmenu_Pre 2270 ${If} $Skip_Page_Startmenu == 1 2271 Abort 2272 ${EndIf} 2273 2274 ${If} $INSTALL_TYPE == 1 2275 ${OrIf} $INSTALL_TYPE == 2 2276 ${OrIf} $INSTALL_TYPE == 3 2277 ReadRegStr $0 HKLM "$Prev_Install_RegKey" "StartMenuFolder" 2278 StrCpy $STARTMENU_FOLDER $0 2279 ${EndIf} 2280 FunctionEnd 2281 2282;-------------------------------- 2283/*# Page_SetConfig 2284 Var Label_SetConfig 2285 Var GroupBox_Language_SetConfig 2286 Var CheckBox_Language_SetConfig 2287 Var GroupBox_ChartDir_SetConfig 2288 Var DirRequest_SetConfig 2289 Var Button_Delete_SetConfig 2290 Var Button_DeleteAll_SetConfig 2291 Var Button_Add_SetConfig 2292 Var ListBox_SetConfig 2293*/ 2294 Function Page_SetConfig 2295 ${If} $Skip_Page_SetConfig == 1 2296 Abort 2297 ${EndIf} 2298 !insertmacro MUI_HEADER_TEXT $(Page_SetConfig_Title) $(Page_SetConfig_Subtitle) 2299 nsDialogs::Create /NOUNLOAD 1018 2300 Pop $0 2301 ${If} $0 == error 2302 Abort 2303 ${EndIf} 2304 2305 ${NSD_CreateLabel} 0 0 100% 16u "$(Label_SetConfig_Text)" 2306 Pop $Label_SetConfig 2307 2308 ${NSD_CreateGroupBox} 0 20u 100% 30u "$(GB_Language_SetConfig_Text)" 2309 Pop $GroupBox_Language_SetConfig 2310 2311 ${NSD_CreateCheckBox} 10u 35u 100% 10u "$(CB_Language_SetConfig_Text)" 2312 Pop $CheckBox_Language_SetConfig 2313 ;StrCmp $CONFIG_SET_LANG "" cont 2314 ${If} $CONFIG_SET_LANG == "" 2315 ${NSD_SetState} $CheckBox_Language_SetConfig ${BST_CHECKED} 2316 Goto cont 2317 ${EndIf} 2318 2319 StrCmp $CONFIG_SET_LANG 0 0 +2 2320 ${NSD_SetState} $CheckBox_Language_SetConfig ${BST_UNCHECKED} 2321 StrCmp $CONFIG_SET_LANG 1 0 +2 2322 ${NSD_SetState} $CheckBox_Language_SetConfig ${BST_CHECKED} 2323 2324 cont: 2325 ${NSD_CreateGroupBox} 0 55u 100% 85u "$(GB_ChartDir_SetConfig_Text)" 2326 Pop $GroupBox_ChartDir_SetConfig 2327 2328 ${NSD_CreateButton} 220u 70u 60u 15u "$(BT_Delete_SetConfig_Text)" 2329 Pop $Button_Delete_SetConfig 2330 GetFunctionAddress $0 Button_Delete_SetConfig_Click 2331 nsDialogs::OnClick /NOUNLOAD $Button_Delete_SetConfig $0 2332 2333 ${NSD_CreateButton} 220u 88u 60u 15u "$(BT_DeleteAll_SetConfig_Text)" 2334 Pop $Button_DeleteAll_SetConfig 2335 GetFunctionAddress $0 Button_DeleteAll_SetConfig_Click 2336 nsDialogs::OnClick /NOUNLOAD $Button_DeleteAll_SetConfig $0 2337 2338 ${NSD_CreateButton} 220u 115u 60u 15u "$(BT_Browse_SetConfig_Text)" 2339 Pop $Button_Add_SetConfig 2340 GetFunctionAddress $0 Button_Add_SetConfig_Click 2341 nsDialogs::OnClick /NOUNLOAD $Button_Add_SetConfig $0 2342 2343 ${NSD_CreateListBox} 10u 70u 200u 60u $(LB_SetConfig) 2344 Pop $ListBox_SetConfig 2345 GetFunctionAddress $0 ListBox_SetConfig_Change 2346 nsDialogs::OnChange /NOUNLOAD $ListBox_SetConfig $0 2347 ${IfNot} $CHART_DIR_EMPTY == 1 2348 SetShellVarContext all 2349 ${If} ${FileExists} "$TEMP\opencpn_chart_dirs.tmp" 2350 ClearErrors 2351 FileOpen $R0 "$TEMP\opencpn_chart_dirs.tmp" r 2352 IfErrors end 2353 loop: 2354 ClearErrors 2355 FileReadUTF16LE $R0 $1 2356 IfErrors end 2357 ${TrimNewLines} $1 $1 2358 SendMessage $ListBox_SetConfig ${LB_ADDSTRING} 0 "STR:$1" 2359 Goto loop 2360 end: 2361 FileClose $R0 2362 ${ElseIf} $INI_EXISTS == 1 2363 StrCpy $R2 0 2364 loop2: 2365 IntOp $R2 $R2 + 1 2366 ReadINIStr $R1 "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" "ChartDirectories" "ChartDir$R2" 2367 StrCmp $R1 "" cont2 2368 ${WordReplace} "$R1" "\\" "\" "+" $R3 2369 ${Explode} $R4 "^" "$R3" 2370 Pop $R5 2371 StrCmp $R5 "" cont2 2372 SendMessage $ListBox_SetConfig ${LB_ADDSTRING} 0 "STR:$R5" 2373 Goto loop2 2374 ${Else} 2375 ReadRegStr $0 HKLM "Software\OpenCPN" "ChartDirs" 2376 StrCmp $0 "" cont2 2377 ${Explode} $3 ";" "$0" 2378 ${For} $1 1 $3 2379 Pop $2 2380 ${TrimNewLines} $2 $2 2381 SendMessage $ListBox_SetConfig ${LB_ADDSTRING} 0 "STR:$2" 2382 ${Next} 2383 ${EndIf} 2384 ${EndIf} 2385 2386 cont2: 2387 Call ListBox_SetConfig_Change 2388 nsDialogs::Show 2389 FunctionEnd 2390 2391 Function Button_Delete_SetConfig_Click 2392 SendMessage $ListBox_SetConfig ${LB_GETCURSEL} 0 0 $0 2393 SendMessage $ListBox_SetConfig ${LB_DELETESTRING} $0 0 2394 Call ListBox_SetConfig_Change 2395 FunctionEnd 2396 2397 Function Button_DeleteAll_SetConfig_Click 2398 SendMessage $ListBox_SetConfig ${LB_RESETCONTENT} 0 0 2399 Call ListBox_SetConfig_Change 2400 FunctionEnd 2401 2402 Function Button_Add_SetConfig_Click 2403 Var /GLOBAL Initial_Dir 2404 StrCmp $Initial_Dir "" 0 +3 2405 SetShellVarContext all 2406 StrCpy $Initial_Dir "$DOCUMENTS" 2407 nsDialogs::SelectFolderDialog /NOUNLOAD "$(Select_Chart_Directory)" "$Initial_Dir" 2408 Pop $0 2409 ${If} $0 == error 2410 Abort 2411 ${EndIf} 2412 StrCpy $Initial_Dir $0 2413 ${NSD_LB_GetCount} $ListBox_SetConfig $2 2414 ${If} $2 > 0 2415 SendMessage $ListBox_SetConfig ${LB_FINDSTRINGEXACT} -1 "STR:$0" $6 2416 ${IfNot} $6 < 0 2417 Goto end 2418 ${EndIf} 2419 ${EndIf} 2420 SendMessage $ListBox_SetConfig ${LB_ADDSTRING} 0 "STR:$0" 2421 end: 2422 Call ListBox_SetConfig_Change 2423 FunctionEnd 2424 2425 Function ListBox_SetConfig_Change 2426 ${NSD_LB_GetCount} $ListBox_SetConfig $0 2427 ${If} $0 > 0 2428 StrCpy $CHART_DIR_EMPTY 0 2429 ${NSD_LB_GetSelection} $ListBox_SetConfig $1 2430 ${If} $1 != "" 2431 EnableWindow $Button_Delete_SetConfig 1 2432 ${Else} 2433 EnableWindow $Button_Delete_SetConfig 0 2434 ${EndIf} 2435 EnableWindow $Button_DeleteAll_SetConfig 1 2436 ${Else} 2437 EnableWindow $Button_Delete_SetConfig 0 2438 EnableWindow $Button_DeleteAll_SetConfig 0 2439 StrCpy $CHART_DIR_EMPTY 1 2440 ${EndIf} 2441 FunctionEnd 2442 2443;-------------------------------- 2444/*# Page_SetConfig_Leave 2445 Var CHART_DIR_TMP_FILE 2446*/ 2447 Function Page_SetConfig_Leave 2448 ${NSD_LB_GetCount} $ListBox_SetConfig $0 2449 ${If} $0 > 0 2450 ClearErrors 2451 FileOpen $R0 "$TEMP\opencpn_chart_dirs.tmp" w 2452 IfErrors done 2453 IntOp $0 $0 - 1 2454 ${For} $1 0 $0 2455 SendMessage $ListBox_SetConfig ${LB_SETCURSEL} $1 0 2456 System::Call "User32::SendMessage(i $ListBox_SetConfig, i ${LB_GETTEXT}, i $1, t .r2)" 2457 FileWriteUTF16LE $R0 $2 2458 FileWriteUTF16LE $R0 "$\r$\n" 2459 ${Next} 2460 FileClose $R0 2461 StrCpy $CHART_DIR_TMP_FILE 1 2462 ${Else} 2463 StrCpy $CHART_DIR_EMPTY 1 2464 ${EndIf} 2465 2466 done: 2467 ${NSD_GetState} $CheckBox_Language_SetConfig $0 2468 ${If} $0 == ${BST_CHECKED} 2469 StrCpy $CONFIG_SET_LANG 1 2470 ${Else} 2471 StrCpy $CONFIG_SET_LANG 0 2472 ${EndIf} 2473 FunctionEnd 2474 2475;-------------------------------- 2476;# Page_Confirm 2477 Var Install_Options 2478 Var TEXT_INSTALL_OPTIONS 2479 Function Page_Confirm 2480 !insertmacro MUI_HEADER_TEXT $(Page_Confirm_Title) $(Page_Confirm_Subtitle) 2481 ;# gather all installation settings and prepare (string) variable '$Install_Options' to display 2482 ;# add the installation type to '$Install_Options' 2483 StrCpy $Install_Options "$(Installation_Type):$\r$\n" 2484 ${If} $Skip_Page_TypeInst != 1 2485 ${Switch} $INSTALL_TYPE 2486 ${Case} 1 2487 StrCpy $Install_Options "$Install_Options$\t$(Type_Reinstall)" 2488 ${Break} 2489 ${Case} 2 2490 StrCpy $Install_Options "$Install_Options$\t$(Type_Upgrade)" 2491 ${Break} 2492 ${Case} 3 2493 StrCpy $Install_Options "$Install_Options$\t$(Type_Downgrade)" 2494 ${Break} 2495 ${Case} 4 2496 StrCpy $Install_Options "$Install_Options$\t$(Type_Parallel_Installation)" 2497 ${Break} 2498 ${Default} 2499 ${Break} 2500 ${EndSwitch} 2501 ${Else} 2502 StrCpy $Install_Options "$Install_Options$\t$(Type_Fresh_Installation)" 2503 ${EndIf} 2504 2505 ;# add the installation directory to '$Install_Options' 2506 StrCpy $Install_Options "$Install_Options$\r$\n$\r$\n$(Installation_Directory):$\r$\n$\t$INSTDIR" 2507 2508 ;# add the delete config settings to '$Install_Options' 2509 ${If} $CONFIG_EXISTS == 1 2510 ${AndIf} $CONFIG_EMPTY != 1 2511 StrCpy $Install_Options "$Install_Options$\r$\n$\r$\n$(Installation_Delete_Config):" 2512 SectionGetFlags ${SecGrpResetConfig} $0 2513 SectionGetFlags ${SecGrpResetConfig} $1 2514 IntOp $0 $0 & ${SF_SELECTED} 2515 IntOp $1 $1 & ${SF_PSELECTED} 2516 StrCmp $0 0 +3 0 2517 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(SecGrpResetConfig_Text)" 2518 Goto cont 2519 2520 StrCmp $1 0 none_selected 0 2521 SectionGetFlags ${SecDeleteConfigFile} $0 2522 IntOp $0 $0 & ${SF_SELECTED} 2523 StrCmp $0 0 +2 0 2524 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(SecDeleteConfigFile_Text)" 2525 SectionGetFlags ${SecDeleteChartDB} $0 2526 IntOp $0 $0 & ${SF_SELECTED} 2527 StrCmp $0 0 +2 0 2528 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(SecDeleteChartDB_Text)" 2529 SectionGetFlags ${SecDeleteSENC} $0 2530 IntOp $0 $0 & ${SF_SELECTED} 2531 StrCmp $0 0 +2 0 2532 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(SecDeleteSENC_Text)" 2533 SectionGetFlags ${SecDeleteCM93} $0 2534 IntOp $0 $0 & ${SF_SELECTED} 2535 StrCmp $0 0 +2 0 2536 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(SecDeleteCM93_Text)" 2537 SectionGetFlags ${SecDeleteNavobjFile} $0 2538 IntOp $0 $0 & ${SF_SELECTED} 2539 StrCmp $0 0 +2 0 2540 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(SecDeleteNavobjFile_Text)" 2541 SectionGetFlags ${SecDeleteLogFile} $0 2542 IntOp $0 $0 & ${SF_SELECTED} 2543 StrCmp $0 0 +2 0 2544 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(SecDeleteLogFile_Text)" 2545 Goto cont 2546 2547 none_selected: 2548 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(text_none)" 2549 2550 cont: 2551 ${EndIf} 2552 2553 ;# add the shortcut settings to '$Install_Options' 2554 StrCpy $Install_Options "$Install_Options$\r$\n$\r$\n$(Create_Shortcuts):" 2555 SectionGetFlags ${SecShortcutStartmenu} $0 2556 IntOp $0 $0 & ${SF_SELECTED} 2557 ${If} $0 != 0 2558 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(Create_Shortcut_Start_Menu): $STARTMENU_FOLDER" 2559 StrCpy $2 1 2560 ${Else} 2561 StrCpy $2 0 2562 ${EndIf} 2563 2564 SectionGetFlags ${SecShortcutDesktop} $0 2565 IntOp $0 $0 & ${SF_SELECTED} 2566 ${If} $0 != 0 2567 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(Create_Shortcut_Desktop): $DESKTOP" 2568 ${Else} 2569 StrCmp $2 0 0 +2 2570 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(text_none)" 2571 ${EndIf} 2572 2573 ;# add the pre-config settings to '$Install_Options' 2574 ${IfNot} ${SectionIsReadOnly} ${SecSetConfig} 2575 ${AndIf} ${SectionIsSelected} ${SecSetConfig} 2576 StrCpy $Install_Options "$Install_Options$\r$\n$\r$\n$(SecSetConfig_Text):" 2577 StrCmp $CONFIG_SET_LANG 1 0 +2 2578 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(CB_Language_SetConfig_Text)" 2579 StrCmp $CHART_DIR_TMP_FILE 1 0 end 2580 IfFileExists "$TEMP\opencpn_chart_dirs.tmp" 0 end 2581 StrCpy $Install_Options "$Install_Options$\r$\n$\t$(GB_ChartDir_SetConfig_Text)" 2582 ClearErrors 2583 FileOpen $0 "$TEMP\opencpn_chart_dirs.tmp" r 2584 IfErrors end 2585 ${Do} 2586 FileReadUTF16LE $0 $1 2587 IfErrors done 2588 ${TrimNewLines} $1 $1 2589 StrCmp $1 "" +2 2590 StrCpy $Install_Options "$Install_Options$\r$\n$\t - $1" 2591 ${Loop} 2592 done: 2593 FileClose $0 2594 end: 2595 ${EndIf} 2596 ;# end '$Install_Options' 2597 2598 nsDialogs::Create /NOUNLOAD 1018 2599 Pop $0 2600 ${If} $0 == error 2601 Abort 2602 ${EndIf} 2603 2604 nsDialogs::CreateControl EDIT "${__NSD_Text_STYLE}|${WS_VSCROLL}|${WS_HSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN}|${ES_READONLY}" "${__NSD_Text_EXSTYLE}" 0 0 100% 100% "$Install_Options" 2605 Pop $TEXT_INSTALL_OPTIONS 2606 2607 nsDialogs::Show 2608 FunctionEnd 2609 2610;# Page_Instfiles_Show 2611 Function Page_Instfiles_Show 2612 w7tbp::Start 2613 FunctionEnd 2614 2615;-------------------------------- 2616;################################################################################################## 2617;# General Installer Functions # 2618;################################################################################################## 2619Function GetAllUsers 2620 ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName" 2621 System::Call 'netapi32::NetUserEnum(w "\\$0",i 0,i 2,*i .R0,i ${NSIS_MAX_STRLEN}, *i .R1,*i .R2,*i .r1)i .r2' 2622 StrCpy $R8 $R0 2623 IntOp $R2 $R2 - 1 2624 ${ForEach} $9 0 $R2 + 1 2625 System::Call "*$R0(w.R9)" 2626 MessageBox MB_OK "[$R9]" 2627 IntOp $R0 $R0 + 4 2628 ${Next} 2629 System::Call 'netapi32.dll::NetApiBufferFree(i R8)i .R1' 2630FunctionEnd 2631 2632 2633Function Hide_SecGrpResetConfig 2634 Push $0 2635 !insertmacro ClearSectionFlag ${SecDeleteConfigFile} ${SF_SELECTED} 2636 SectionSetText ${SecDeleteConfigFile} "" 2637 !insertmacro ClearSectionFlag ${SecDeleteChartDB} ${SF_SELECTED} 2638 SectionSetText ${SecDeleteChartDB} "" 2639 !insertmacro ClearSectionFlag ${SecDeleteSENC} ${SF_SELECTED} 2640 SectionSetText ${SecDeleteSENC} "" 2641 !insertmacro ClearSectionFlag ${SecDeleteCM93} ${SF_SELECTED} 2642 SectionSetText ${SecDeleteCM93} "" 2643 !insertmacro ClearSectionFlag ${SecDeleteNavobjFile} ${SF_SELECTED} 2644 SectionSetText ${SecDeleteNavobjFile} "" 2645 !insertmacro ClearSectionFlag ${SecDeleteLogFile} ${SF_SELECTED} 2646 SectionSetText ${SecDeleteLogFile} "" 2647 !insertmacro ClearSectionFlag ${SecGrpResetConfig} ${SF_SECGRP} 2648 !insertmacro ClearSectionFlag ${SecGrpResetConfig} ${SF_SELECTED} 2649 SectionSetFlags ${SecGrpResetConfig} 0 2650 SectionSetText ${SecGrpResetConfig} "" 2651 IntOp $0 ${SecDeleteLogFile} + 1 2652 !insertmacro ClearSectionFlag $0 ${SF_SECGRPEND} 2653 SectionSetText $0 "" 2654 Pop $0 2655FunctionEnd 2656 2657 2658Function Check_Config_Exists 2659 ;# Look for config dir ("%APPDATA%\opencpn) and the several config files 2660 SetShellVarContext all 2661 2662 ${IfNot} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" 2663 ${If} ${FileExists} "$USERS_APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" 2664 CreateDirectory "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" 2665 Sleep 250 2666 AccessControl::GrantOnFile "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" "(BU)" "GenericRead + GenericExecute + GenericWrite + Delete + FullAccess" 2667 CopyFiles /SILENT "$USERS_APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" 2668 ${ElseIf} ${FileExists} "$ADMIN_APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" 2669 CreateDirectory "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" 2670 Sleep 250 2671 AccessControl::GrantOnFile "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" "(BU)" "GenericRead + GenericExecute + GenericWrite + Delete + FullAccess" 2672 CopyFiles /SILENT "$ADMIN_APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@" 2673 ${EndIf} 2674 2675 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" 2676 DeleteINISec "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" Directories 2677 ${EndIf} 2678 ${EndIf} 2679 2680 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\*.*" 2681 StrCpy $CONFIG_EXISTS 1 2682 SectionSetText ${SecGrpResetConfig} $(SecGrpResetConfig_Text) 2683 ${EndIf} 2684 StrCpy $Count_SecGrpResetConfig 0 2685 ${If} $CONFIG_EXISTS == 1 2686 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" 2687 StrCpy $INI_EXISTS 1 2688 IntOp $Count_SecGrpResetConfig $Count_SecGrpResetConfig + 1 2689 SectionSetText ${SecDeleteConfigFile} $(SecDeleteConfigFile_Text) 2690 ${Else} 2691 !insertmacro ClearSectionFlag ${SecDeleteConfigFile} ${SF_SELECTED} 2692 SectionSetText ${SecDeleteConfigFile} "" 2693 ${EndIf} 2694 2695 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\CHRTLIST.DAT" 2696 StrCpy $CHARTDB_EXISTS 1 2697 IntOp $Count_SecGrpResetConfig $Count_SecGrpResetConfig + 1 2698 SectionSetText ${SecDeleteChartDB} $(SecDeleteChartDB_Text) 2699 ${Else} 2700 !insertmacro ClearSectionFlag ${SecDeleteChartDB} ${SF_SELECTED} 2701 SectionSetText ${SecDeleteChartDB} "" 2702 ${EndIf} 2703 2704 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\SENC\*.*" 2705 StrCpy $SENC_EXISTS 1 2706 IntOp $Count_SecGrpResetConfig $Count_SecGrpResetConfig + 1 2707 SectionSetText ${SecDeleteSENC} $(SecDeleteSENC_Text) 2708 ${Else} 2709 !insertmacro ClearSectionFlag ${SecDeleteSENC} ${SF_SELECTED} 2710 SectionSetText ${SecDeleteSENC} "" 2711 ${EndIf} 2712 2713 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\cm93\*.*" 2714 StrCpy $CM93_EXISTS 1 2715 IntOp $Count_SecGrpResetConfig $Count_SecGrpResetConfig + 1 2716 SectionSetText ${SecDeleteCM93} $(SecDeleteCM93_Text) 2717 ${Else} 2718 !insertmacro ClearSectionFlag ${SecDeleteCM93} ${SF_SELECTED} 2719 SectionSetText ${SecDeleteCM93} "" 2720 ${EndIf} 2721 2722 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\navobj.xml" 2723 StrCpy $NAVOBJ_EXISTS 1 2724 IntOp $Count_SecGrpResetConfig $Count_SecGrpResetConfig + 1 2725 SectionSetText ${SecDeleteNavobjFile} $(SecDeleteNavobjFile_Text) 2726 ${Else} 2727 !insertmacro ClearSectionFlag ${SecDeleteNavobjFile} ${SF_SELECTED} 2728 SectionSetText ${SecDeleteNavobjFile} "" 2729 ${EndIf} 2730 2731 ${If} ${FileExists} "$APPDATA\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.log" 2732 StrCpy $LOG_EXISTS 1 2733 IntOp $Count_SecGrpResetConfig $Count_SecGrpResetConfig + 1 2734 SectionSetText ${SecDeleteLogFile} $(SecDeleteLogFile_Text) 2735 ${Else} 2736 !insertmacro ClearSectionFlag ${SecDeleteLogFile} ${SF_SELECTED} 2737 SectionSetText ${SecDeleteLogFile} "" 2738 ${EndIf} 2739 2740 ${If} $Count_SecGrpResetConfig == 0 2741 StrCpy $CONFIG_EMPTY 1 2742 ${EndIf} 2743 2744 !insertmacro ClearSectionFlag ${SecSetConfig} ${SF_SELECTED} 2745 IntOp $0 ${SF_RO} | ${SF_BOLD} 2746 SectionSetFlags ${SecSetConfig} $0 2747 ;SectionSetFlags ${SecSetConfig} ${SF_RO} 2748 StrCpy $SetConfig 0 2749 ${EndIf} 2750FunctionEnd 2751 2752 2753Function Reg_Scan_Old_Versions_HKLM 2754 ;# Registry look-up 2755 ;# Versions prior to 2.2.727 write RegKey "OpenCPN_is1" to "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" 2756 ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1 "DisplayName" 2757 ${If} $0 != "" 2758 ${StrFilter} "$0" "31" "." " " $1 2759 StrCpy $LM_VERSION "$1" 2760 ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1 "UninstallString" 2761 ${StrFilter} "$0" "" "" "$\"" $2 2762 ${If} ${FileExists} "$2" 2763 ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1 "QuietUninstallString" 2764 ${StrFilter} "$0" "" "" "$\"" $3 2765 StrCpy $LM_VERSION_UNINST $3 2766 ReadRegStr $4 HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1 "InstallLocation" 2767 ${TrimNewLines} $4 $4 2768 ${If} ${FileExists} "$4opencpn.exe" 2769 ${AndIf} ${FileExists} "$4unins*.exe" 2770 ;# check if last character of $4 is a "\" and if so remove it 2771 ${RIndexOf} $6 "$4" "\" 2772 ${If} $6 == 1 2773 ${WordReplace} "$4" "\" "" "-1" $4 2774 ${EndIf} 2775 2776 StrCpy $LM_VERSION_INST $4 2777 IntOp $OLD_INSTALLS $OLD_INSTALLS + 1 2778 ;StrCpy $VERSION_NEWER 1 2779 ${Else} 2780 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN_is1" 2781 StrCpy $LM_VERSION "" 2782 StrCpy $LM_VERSION_UNINST "" 2783 ${EndIf} 2784 ${EndIf} 2785 ${EndIf} 2786FunctionEnd 2787 2788 2789Function EnumProfileList 2790 ${EnumHKU} Callback_EnumProfileList opencpn-inst-tmp-sid 2791FunctionEnd 2792 2793 2794Function Callback_EnumProfileList 2795 ;# Get the SID or tmpkey from the stack 2796 Pop $SID 2797 ClearErrors 2798 ${If} ${FileExists} "$TEMP\opencpn_users_sid.tmp" 2799 FileOpen $R0 "$TEMP\opencpn_users_sid.tmp" a 2800 FileSeek $R0 0 END 2801 ${Else} 2802 FileOpen $R0 "$TEMP\opencpn_users_sid.tmp" w 2803 ${EndIf} 2804 2805 IfErrors done 2806 FileWriteUTF16LE $R0 "$SID" 2807 FileWriteUTF16LE $R0 "$\r$\n" 2808 FileWriteUTF16LE $R0 "$USERPROFILE" 2809 FileWriteUTF16LE $R0 "$\r$\n" 2810 FileClose $R0 2811 done: 2812FunctionEnd 2813 2814 2815Function Get_Users_Values 2816 Var /GLOBAL tmp_file_handle 2817 StrCpy $SID "" 2818 ClearErrors 2819 ${If} ${FileExists} "$TEMP\opencpn_users_sid.tmp" 2820 FileOpen $tmp_file_handle "$TEMP\opencpn_users_sid.tmp" r 2821 IfErrors end 2822 ${Do} 2823 FileReadUTF16LE $tmp_file_handle $SID 2824 FileReadUTF16LE $tmp_file_handle $USERPROFILE 2825 StrCmp $SID "" done 2826 ${TrimNewLines} $SID $SID 2827 ${TrimNewLines} $USERPROFILE $USERPROFILE 2828 ;# List of functions to call 2829 Call Users_Appdata_Paths 2830 Call Users_StartMenu_Paths 2831 Call Users_Desktop_Paths 2832 Call Users_Personal_Paths 2833 Call Reg_Scan_Old_Versions_HKCU 2834 ${Loop} 2835 done: 2836 FileClose $tmp_file_handle 2837 StrCpy $SID "" 2838 StrCpy $USERPROFILE "" 2839 ${EndIf} 2840 end: 2841FunctionEnd 2842 2843 2844Function Users_Appdata_Paths 2845 ReadRegStr $1 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" AppData 2846 ${WordReplace} "$1" "%USERPROFILE%" "$USERPROFILE" "+" $2 2847 ExpandEnvStrings $2 $2 2848 StrCmp $2 "" done 2849 2850 StrCpy $5 "none" 2851 ;# check if an OpenCPN config folder exists in the given path 2852 ${If} ${FileExists} "$2\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" 2853 ReadINIStr $3 "$2\@CPACK_NSIS_PACKAGE_NAME_LC@\opencpn.ini" Directories S57DataLocation 2854 ${WordReplace} "$3" "\\" "\" "+" $4 2855 ${WordFind} "$4" "\" "-2{*" $5 2856 StrCmp $5 "" 0 +2 2857 StrCpy $5 "none" 2858 ${EndIf} 2859 2860 ClearErrors 2861 ${If} ${FileExists} "$TEMP\opencpn_appdata.tmp" 2862 FileOpen $R0 "$TEMP\opencpn_appdata.tmp" a 2863 FileSeek $R0 0 END 2864 ${Else} 2865 FileOpen $R0 "$TEMP\opencpn_appdata.tmp" w 2866 ${EndIf} 2867 IfErrors done 2868 FileWriteUTF16LE $R0 "$SID" 2869 FileWriteUTF16LE $R0 "$\r$\n" 2870 FileWriteUTF16LE $R0 "$2" 2871 FileWriteUTF16LE $R0 "$\r$\n" 2872 FileWriteUTF16LE $R0 "$5" 2873 FileWriteUTF16LE $R0 "$\r$\n" 2874 FileClose $R0 2875 done: 2876FunctionEnd 2877 2878 2879Function Users_Personal_Paths 2880 ReadRegStr $1 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" Personal 2881 ${WordReplace} "$1" "%USERPROFILE%" "$USERPROFILE" "+" $2 2882 ExpandEnvStrings $2 $2 2883 2884 ClearErrors 2885 ${If} ${FileExists} "$TEMP\opencpn_personal.tmp" 2886 FileOpen $R0 "$TEMP\opencpn_personal.tmp" a 2887 IfErrors done 2888 FileSeek $R0 0 END 2889 ${Else} 2890 FileOpen $R0 "$TEMP\opencpn_personal.tmp" w 2891 IfErrors done 2892 ${EndIf} 2893 2894 FileWriteUTF16LE $R0 "$SID" 2895 FileWriteUTF16LE $R0 "$\r$\n" 2896 FileWriteUTF16LE $R0 "$2" 2897 FileWriteUTF16LE $R0 "$\r$\n" 2898 FileClose $R0 2899 done: 2900FunctionEnd 2901 2902 2903Function Users_StartMenu_Paths 2904 ReadRegStr $1 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Start Menu" 2905 ${WordReplace} "$1" "%USERPROFILE%" "$USERPROFILE" "+" $2 2906 ExpandEnvStrings $2 $2 2907 2908 ClearErrors 2909 ${If} ${FileExists} "$TEMP\opencpn_startmenu.tmp" 2910 FileOpen $R0 "$TEMP\opencpn_startmenu.tmp" a 2911 FileSeek $R0 0 END 2912 ${Else} 2913 FileOpen $R0 "$TEMP\opencpn_startmenu.tmp" w 2914 ${EndIf} 2915 IfErrors done 2916 FileWriteUTF16LE $R0 "$SID" 2917 FileWriteUTF16LE $R0 "$\r$\n" 2918 FileWriteUTF16LE $R0 "$2" 2919 FileWriteUTF16LE $R0 "$\r$\n" 2920 FileClose $R0 2921 done: 2922FunctionEnd 2923 2924 2925Function Users_Desktop_Paths 2926 ReadRegStr $1 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" Desktop 2927 ${WordReplace} "$1" "%USERPROFILE%" "$USERPROFILE" "+" $2 2928 ExpandEnvStrings $2 $2 2929 2930 ClearErrors 2931 ${If} ${FileExists} "$TEMP\opencpn_desktop.tmp" 2932 FileOpen $R0 "$TEMP\opencpn_desktop.tmp" a 2933 FileSeek $R0 0 END 2934 ${Else} 2935 FileOpen $R0 "$TEMP\opencpn_desktop.tmp" w 2936 ${EndIf} 2937 IfErrors done 2938 FileWriteUTF16LE $R0 "$SID" 2939 FileWriteUTF16LE $R0 "$\r$\n" 2940 FileWriteUTF16LE $R0 "$2" 2941 FileWriteUTF16LE $R0 "$\r$\n" 2942 FileClose $R0 2943 done: 2944FunctionEnd 2945 2946 2947;Var latest_version 2948;Var latest_pathexe 2949Function Reg_Scan_Old_Versions_HKCU 2950 ;# Versions from 2.2.727 up to 2.2.xxxx write RegKey "OpenCPN" to "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\" 2951 ;# and also RegKey "OpenCPN <version>" to "HKCU\Software\opencpn.org\" 2952 ;# Find latest installed version => it's the one found in "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN" 2953 2954 ReadRegStr $0 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN" "DisplayVersion" 2955 ${If} $0 != "" 2956 StrCpy $latest_version $0 2957 ReadRegStr $0 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN" "DisplayIcon" 2958 StrCpy $latest_pathexe $0 2959 ReadRegStr $0 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN" "UninstallString" 2960 ;StrCpy $CU_VERSION_UNINST $0 2961 ${WordFind} "$0" "\" "-2{*" $1 2962 ${If} ${FileExists} "$1\opencpn.exe" 2963 ${AndIf} ${FileExists} "$1\unins*.exe" 2964 ClearErrors 2965 ${If} ${FileExists} "$TEMP\opencpn_old_uninstall_regkeys.tmp" 2966 FileOpen $R0 "$TEMP\opencpn_old_uninstall_regkeys.tmp" a 2967 FileSeek $R0 0 END 2968 ${Else} 2969 FileOpen $R0 "$TEMP\opencpn_old_uninstall_regkeys.tmp" w 2970 ${EndIf} 2971 2972 IfErrors done 2973 FileWriteUTF16LE $R0 "$SID$\r$\n" 2974 FileWriteUTF16LE $R0 "$SID\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN$\r$\n" 2975 FileWriteUTF16LE $R0 "$1$\r$\n" 2976 FileClose $R0 2977 ${Else} 2978 DeleteRegKey HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenCPN" 2979 ${EndIf} 2980 ${EndIf} 2981 2982 done: 2983 ClearErrors 2984 ${Do} 2985 Pop $0 2986 IfErrors empty 2987 ${Loop} 2988 empty: 2989 StrCpy $0 0 2990 StrCpy $1 "" 2991 ${Do} 2992 EnumRegKey $1 HKU "$SID\Software\opencpn.org" $0 2993 StrCmp $1 "" done1 2994 IntOp $0 $0 + 1 2995 Push $1 2996 ${Loop} 2997 done1: 2998 ${If} $0 > 0 2999 ClearErrors 3000 ${If} ${FileExists} "$TEMP\opencpn_old_installs.tmp" 3001 FileOpen $R0 "$TEMP\opencpn_old_installs.tmp" a 3002 FileSeek $R0 0 END 3003 ${Else} 3004 FileOpen $R0 "$TEMP\opencpn_old_installs.tmp" w 3005 ${EndIf} 3006 IfErrors done2 3007 ${Do} 3008 Pop $R1 3009 IfErrors finished 3010 ${StrFilter} "$R1" "31" "." " " $R2 ;# R2 = version 3011 ;StrCpy $CU_VERSION $R2 3012 ReadRegStr $R3 HKU "$SID\Software\opencpn.org\$R1" "" ;# R3 = install path 3013 ReadRegStr $R4 HKU "$SID\Software\opencpn.org\$R1" "Start Menu Folder" ;# R4 = Start Menu Folder 3014 ReadRegStr $R5 HKU "$SID\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Start Menu" ;# R5 = Start Menu Path 3015 ${WordReplace} "$R5" "%USERPROFILE%" "$USERPROFILE" "+" $R5 3016 ExpandEnvStrings $R5 $R5 3017 ;StrCpy $CU_VERSION_INST "$R3\" 3018 ${If} "$R3\opencpn.exe" == $latest_pathexe 3019 ${AndIf} $R2 != $latest_version 3020 DeleteRegKey HKU "$SID\Software\opencpn.org\$R1" 3021 ${ElseIf} ${FileExists} "$R3\opencpn.exe" 3022 ${AndIf} ${FileExists} "$R3\unins*.exe" 3023 FileWriteUTF16LE $R0 "$SID\Software\opencpn.org\$R1" 3024 FileWriteUTF16LE $R0 "$\r$\n" 3025 FileWriteUTF16LE $R0 "$R5\$R4" 3026 FileWriteUTF16LE $R0 "$\r$\n" 3027 FileWriteUTF16LE $R0 "$R3" 3028 FileWriteUTF16LE $R0 "$\r$\n" 3029 IntOp $OLD_INSTALLS $OLD_INSTALLS + 1 3030 ;StrCpy $VERSION_NEWER 1 3031 ${Else} 3032 DeleteRegKey HKU "$SID\Software\opencpn.org\$R1" 3033 DeleteRegKey /ifempty HKU "$SID\Software\opencpn.org" 3034 ${EndIf} 3035 ${Loop} 3036 finished: 3037 FileClose $R0 3038 ${Else} 3039 DeleteRegKey HKU "$SID\Software\opencpn.org" 3040 ${EndIf} 3041 3042 done2: 3043 StrCpy $latest_version "" 3044 StrCpy $latest_pathexe "" 3045FunctionEnd 3046 3047 3048Function Quick_Scan_Old_Versions 3049 ;# Scan the given Drive for file "opencpn.exe" 3050 ${If} ${FileExists} "$TEMP\opencpn_personal.tmp" 3051 ClearErrors 3052 FileOpen $R0 "$TEMP\opencpn_personal.tmp" r 3053 IfErrors end 3054 ${Do} 3055 FileReadUTF16LE $R0 $R1 3056 FileReadUTF16LE $R0 $R2 3057 IfErrors done 3058 StrCmp $R2 "" done 3059 ${TrimNewLines} $R2 $R2 3060 ${Locate} "$R2" "/L=F /M=opencpn.exe" "Found_OpenCPN_Installation" 3061 ${Loop} 3062 done: 3063 FileClose $R0 3064 ${EndIf} 3065 3066 end: 3067 ${Locate} "$PROGRAMFILES" "/L=F /M=opencpn.exe" "Found_OpenCPN_Installation" 3068FunctionEnd 3069 3070 3071Function Found_OpenCPN_Installation 3072 Push $R0 3073 Push $R1 3074 ${If} ${FileExists} "$R8\unins*.exe" 3075 ${If} ${FileExists} "$TEMP\opencpn_prev_installs.tmp" 3076 ClearErrors 3077 FileOpen $R1 "$TEMP\opencpn_prev_installs.tmp" r 3078 IfErrors cont 3079 ${Do} 3080 FileReadUTF16LE $R1 $R2 3081 FileReadUTF16LE $R1 $R3 3082 StrCmp $R2 "" done 3083 ${TrimNewLines} $R2 $R2 3084 ${TrimNewLines} $R3 $R3 3085 StrCmp $R3 $R8 found 3086 ${LoopUntil} $R2 == "" 3087 done: 3088 FileClose $R1 3089 Goto cont 3090 3091 found: 3092 FileClose $R1 3093 Goto end 3094 ${EndIf} 3095 3096 cont: 3097 IntOp $counter_tmp $counter_tmp + 1 3098 ClearErrors 3099 ${IfNot} ${FileExists} "$TEMP\opencpn_hdd_quick_scan.tmp" 3100 FileOpen $R0 "$TEMP\opencpn_hdd_quick_scan.tmp" w 3101 IfErrors end 3102 ${Else} 3103 FileOpen $R0 "$TEMP\opencpn_hdd_quick_scan.tmp" a 3104 IfErrors end 3105 FileSeek $R0 0 END 3106 ${EndIf} 3107 3108 FileWriteUTF16LE $R0 "$R8" 3109 FileWriteUTF16LE $R0 "$\r$\n" 3110 FileClose $R0 3111 ${EndIf} 3112 3113 end: 3114 Pop $R1 3115 Pop $R0 3116 Push $0 3117FunctionEnd 3118 3119 3120;Var counter_tmp 3121Function Full_Scan_Old_Versions 3122 ;# Get all HDD Drive Letters on the system 3123 StrCpy $counter_tmp 0 3124 ${GetDrives} "HDD" "Scan_Drive" 3125FunctionEnd 3126 3127 3128Function Scan_Drive 3129 ;# Scan the given Drive for file "opencpn.exe" 3130 /*;#DEBUG - scan only crtain drives 3131 ${IfNot} $9 == "D:\" 3132 ;${AndIfNot} $9 == "F:\" 3133 Goto end 3134 ${EndIf} 3135 ;#DEBUG End */ 3136 StrCpy $3 "$(Banner_Scan_Drive)" 3137 GetDlgItem $2 $Banner_Handle 76 3138 SendMessage $2 ${WM_SETTEXT} 0 "STR:$3" 3139 ${Locate} "$9" "/L=F /M=opencpn.exe" "Found_OCPN_Exe" 3140 end: 3141 Push $0 3142FunctionEnd 3143 3144 3145Function Found_OCPN_Exe 3146 Push $1 3147 ClearErrors 3148 StrCpy $1 0 3149 StrCpy $2 0 3150 ${WordFind} "$R8" "\RECYCLER\" "E*" $1 3151 ${WordFind} "$R8" "\$$Recycle.Bin" "E*" $2 3152 IfErrors 0 cont1 3153 ${If} $1 == 1 3154 ${AndIf} $2 == 1 3155 Goto cont2 3156 ${EndIf} 3157 3158 cont1: 3159 ${If} $1 > 0 3160 ${OrIf} $2 > 0 3161 Goto end 3162 ${EndIf} 3163 3164 cont2: 3165 ${If} ${FileExists} "$R8\unins*.exe" 3166 ${If} ${FileExists} "$TEMP\opencpn_prev_installs.tmp" 3167 ClearErrors 3168 FileOpen $R1 "$TEMP\opencpn_prev_installs.tmp" r 3169 IfErrors cont3 3170 ${Do} 3171 FileReadUTF16LE $R1 $R2 3172 FileReadUTF16LE $R1 $R3 3173 StrCmp $R2 "" done 3174 ${TrimNewLines} $R2 $R2 3175 ${TrimNewLines} $R3 $R3 3176 StrCmp $R3 $R8 found 3177 ${LoopUntil} $R2 == "" 3178 done: 3179 FileClose $R1 3180 Goto cont3 3181 3182 found: 3183 FileClose $R1 3184 Goto end 3185 ${EndIf} 3186 3187 cont3: 3188 IntOp $counter_tmp $counter_tmp + 1 3189 GetDlgItem $2 $Banner_Handle 1030 3190 StrCmp $counter_tmp 1 0 +3 3191 StrCpy $R4 "$(Banner_Installation_Found_Singular)" 3192 Goto +2 3193 StrCpy $R4 "$(Banner_Installation_Found_Plural)" 3194 SendMessage $2 ${WM_SETTEXT} 0 "STR:$R4" 3195 SendMessage $ListBox_CleanUp ${LB_ADDSTRING} 0 "STR:$R8" 3196 ClearErrors 3197 ${IfNot} ${FileExists} "$TEMP\opencpn_hdd_full_scan.tmp" 3198 FileOpen $R0 "$TEMP\opencpn_hdd_full_scan.tmp" w 3199 IfErrors end 3200 ${Else} 3201 FileOpen $R0 "$TEMP\opencpn_hdd_full_scan.tmp" a 3202 IfErrors end 3203 FileSeek $R0 0 END 3204 ${EndIf} 3205 3206 FileWriteUTF16LE $R0 "$R8" 3207 FileWriteUTF16LE $R0 "$\r$\n" 3208 FileClose $R0 3209 end: 3210 ${EndIf} 3211 Pop $1 3212 Push $0 3213FunctionEnd 3214 3215 3216Function Delete_Installation_Dir 3217 StrCmp $Uninstall_Path_Tmp "" end 3218 ;# Check subdirs and remove them recursive ... 3219 ${If} ${FileExists} "$Uninstall_Path_Tmp\doc\*.*" 3220 RMDir /r "$Uninstall_Path_Tmp\doc" 3221 ${EndIf} 3222 3223 ${If} ${FileExists} "$Uninstall_Path_Tmp\lang\*.*" 3224 RMDir /r "$Uninstall_Path_Tmp\lang" 3225 ${EndIf} 3226 3227 ${If} ${FileExists} "$Uninstall_Path_Tmp\Microsoft.VC80.CRT\*.*" 3228 RMDir /r "$Uninstall_Path_Tmp\Microsoft.VC80.CRT" 3229 ${EndIf} 3230 3231 ${If} ${FileExists} "$Uninstall_Path_Tmp\s57data\*.*" 3232 RMDir /r "$Uninstall_Path_Tmp\s57data" 3233 ${EndIf} 3234 3235 ${If} ${FileExists} "$Uninstall_Path_Tmp\sounds\*.*" 3236 RMDir /r "$Uninstall_Path_Tmp\sounds" 3237 ${EndIf} 3238 3239 ${If} ${FileExists} "$Uninstall_Path_Tmp\TCDATA\*.*" 3240 RMDir /r "$Uninstall_Path_Tmp\TCDATA" 3241 ${EndIf} 3242 3243 ${If} ${FileExists} "$Uninstall_Path_Tmp\gshhs\*.*" 3244 RMDir /r "$Uninstall_Path_Tmp\gshhs" 3245 ${EndIf} 3246 3247 ${If} ${FileExists} "$Uninstall_Path_Tmp\plugins\*.*" 3248 RMDir /r "$Uninstall_Path_Tmp\plugins" 3249 ${EndIf} 3250 3251 ${If} ${FileExists} "$Uninstall_Path_Tmp\share\*.*" 3252 RMDir /r "$Uninstall_Path_Tmp\share" 3253 ${EndIf} 3254 3255 ;# Check files and delete them ... 3256 ${If} ${FileExists} "$Uninstall_Path_Tmp\opencpn.exe" 3257 Delete "$Uninstall_Path_Tmp\opencpn.exe" 3258 ${EndIf} 3259 3260 ${If} ${FileExists} "$Uninstall_Path_Tmp\license.txt" 3261 Delete "$Uninstall_Path_Tmp\license.txt" 3262 ${EndIf} 3263 3264 ${If} ${FileExists} "$Uninstall_Path_Tmp\unins000.dat" 3265 Delete "$Uninstall_Path_Tmp\unins000.dat" 3266 ${EndIf} 3267 3268 ${If} ${FileExists} "$Uninstall_Path_Tmp\unins000.exe" 3269 Delete "$Uninstall_Path_Tmp\unins000.exe" 3270 ${EndIf} 3271 3272 ${If} ${FileExists} "$Uninstall_Path_Tmp\install.log" 3273 Delete "$Uninstall_Path_Tmp\install.log" 3274 ${EndIf} 3275 3276 ${If} ${FileExists} "$Uninstall_Path_Tmp\install.log" 3277 Delete "$Uninstall_Path_Tmp\install.log" 3278 ${EndIf} 3279 3280 Push $0 3281 Push $1 3282 Push $2 3283 Push $R9 3284 Push $R8 3285 Push $R7 3286 Push $R6 3287 ;# Find the Uninstall file 3288 ${Locate} "$Uninstall_Path_Tmp" "/L=F /M=Uninstall*.exe /G=0" "Delete_Located_File_Single" 3289 ;# Find the wx.. DLLs 3290 ${Locate} "$Uninstall_Path_Tmp" "/L=F /M=wx*.dll /G=0" "Delete_Located_File_Multi" 3291 ;# Dummy call of Locate as it does not properly close its handle and so the dir cannot be deleted though it might be empty 3292 ${Locate} "C:\" "/L=DE /M=*.* /G=0" "Dummy_Function" 3293 3294 ;# Remove the installation dir ($Uninstall_Path_Tmp) if empty 3295 RMDir "$Uninstall_Path_Tmp" 3296 ${If} ${FileExists} "$Uninstall_Path_Tmp\*.*" 3297 Sleep 250 3298 RMDir "$Uninstall_Path_Tmp" 3299 ${EndIf} 3300 3301 Pop $R6 3302 Pop $R7 3303 Pop $R8 3304 Pop $R9 3305 Pop $2 3306 Pop $1 3307 Pop $0 3308 end: 3309FunctionEnd 3310 ;# Helper-Functions for Delete_Installation_Dir 3311 Function Delete_Located_File_Single 3312 Delete "$R9" 3313 StrCpy $0 StopLocate 3314 Push $0 3315 FunctionEnd 3316 3317 Function Delete_Located_File_Multi 3318 Delete "$R9" 3319 Push $0 3320 FunctionEnd 3321 3322 Function Dummy_Function 3323 StrCpy $0 StopLocate 3324 Push $0 3325 FunctionEnd 3326 ;# End Helper-Functions 3327 3328 3329Function ExecAppFile 3330 !insertmacro UAC_AsUser_ExecShell 'open' '$INSTDIR\opencpn.exe' '' '$INSTDIR' '' 3331 loop: 3332 System::Call user32::GetForegroundWindow()i.r0 3333 Sleep 200 3334 IntCmpU $0 $hwndparent loop 3335FunctionEnd 3336 3337 3338Function DU2Pix 3339 Pop $4 3340 Pop $3 3341 Pop $2 3342 Pop $1 3343 IntOp $1 $1 * $BU_X 3344 IntOp $1 $1 / 4 3345 IntOp $2 $2 * $BU_Y 3346 IntOp $2 $2 / 8 3347 IntOp $3 $3 * $BU_X 3348 IntOp $3 $3 / 4 3349 IntOp $4 $4 * $BU_Y 3350 IntOp $4 $4 / 8 3351FunctionEnd 3352 3353 3354;!define LVM_GETITEMCOUNT 0x1004 ;# ANSI 3355;!define LVM_GETITEMTEXT 0x102D ;# ANSI 3356!ifndef LVM_GETITEMCOUNT 3357 !define LVM_GETITEMCOUNT 0x1004 3358 !define LVM_GETITEMTEXT 0x1073 3359!endif 3360 3361Function DumpLog 3362 Exch $5 3363 Push $0 3364 Push $1 3365 Push $2 3366 Push $3 3367 Push $4 3368 Push $6 3369 3370 FindWindow $0 "#32770" "" $HWNDPARENT 3371 GetDlgItem $0 $0 1016 3372 StrCmp $0 0 error 3373 FileOpen $5 $5 "w" 3374 FileWriteWord $5 0xfeff ; Write the BOM 3375 StrCmp $5 0 error 3376 SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6 3377 System::StrAlloc ${NSIS_MAX_STRLEN} 3378 Pop $3 3379 StrCpy $2 0 3380 System::Call "*(i, i, i, i, i, i, i, i, i) i \ 3381 (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1" 3382 loop: StrCmp $2 $6 done 3383 System::Call "User32::SendMessageW(i, i, i, i) i \ 3384 ($0, ${LVM_GETITEMTEXT}, $2, r1)" 3385 System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)" 3386 FileWriteUTF16LE $5 "$4$\r$\n" 3387 IntOp $2 $2 + 1 3388 Goto loop 3389 done: 3390 FileClose $5 3391 System::Free $1 3392 System::Free $3 3393 Goto exit 3394 error: 3395 MessageBox MB_OK error 3396 exit: 3397 Pop $6 3398 Pop $4 3399 Pop $3 3400 Pop $2 3401 Pop $1 3402 Pop $0 3403 Exch $5 3404FunctionEnd 3405 3406 3407Function Write_Reg_ChartDirs 3408 ClearErrors 3409 FileOpen $R0 "$TEMP\opencpn_chart_dirs.tmp" r 3410 IfErrors end 3411 loop: 3412 FileReadUTF16LE $R0 $R1 3413 IfErrors done 3414 ${TrimNewLines} $R1 $R1 3415 ${If} $REG_CHARTDIRS == "" 3416 StrCpy $REG_CHARTDIRS "$R1" 3417 ${Else} 3418 StrCpy $REG_CHARTDIRS "$REG_CHARTDIRS;$R1" 3419 ${EndIf} 3420 Goto loop 3421 done: 3422 FileClose $R0 3423 WriteRegStr HKLM "Software\OpenCPN" "ChartDirs" $REG_CHARTDIRS 3424 end: 3425FunctionEnd 3426 3427 3428Function IndexOf 3429 Exch $R0 3430 Exch 3431 Exch $R1 3432 Push $R2 3433 Push $R3 3434 3435 StrCpy $R3 $R0 3436 StrCpy $R0 -1 3437 IntOp $R0 $R0 + 1 3438 StrCpy $R2 $R3 1 $R0 3439 StrCmp $R2 "" +2 3440 StrCmp $R2 $R1 +2 -3 3441 3442 StrCpy $R0 -1 3443 3444 Pop $R3 3445 Pop $R2 3446 Pop $R1 3447 Exch $R0 3448FunctionEnd 3449 3450 3451Function RIndexOf 3452 Exch $R0 3453 Exch 3454 Exch $R1 3455 Push $R2 3456 Push $R3 3457 3458 StrCpy $R3 $R0 3459 StrCpy $R0 0 3460 IntOp $R0 $R0 + 1 3461 StrCpy $R2 $R3 1 -$R0 3462 StrCmp $R2 "" +2 3463 StrCmp $R2 $R1 +2 -3 3464 3465 StrCpy $R0 -1 3466 3467 Pop $R3 3468 Pop $R2 3469 Pop $R1 3470 Exch $R0 3471FunctionEnd 3472 3473;################################################################################################## 3474;# Uninstaller Functions # 3475;################################################################################################## 3476;# un.onInit Function 3477Function un.onInit 3478 ;Prevent multiple instances of the uninstaller 3479 ${IfNot} ${UAC_IsInnerInstance} 3480 System::Call 'kernel32::CreateMutexW(i 0, i 0, t "ocpn_uninst_@CPACK_PACKAGE_VERSION@") i .r1 ?e' 3481 Pop $R0 3482 StrCmp $R0 0 +3 3483 MessageBox MB_OK|MB_ICONEXCLAMATION "$(Uninstaller_Running)" 3484 Abort 3485 ${EndIf} 3486 3487 Call un.GetUserInfo 3488 StrCpy $USERS_NAME $USERNAME 3489 3490 ;# Macros to be inserted 3491 ${If} $IS_ADMIN == 1 3492 !insertmacro MUI_UNGETLANGUAGE 3493 ${EndIf} 3494 3495 StrCpy $USERS_APPDATA $APPDATA 3496 3497 ;# UAC check if user has Admin privileges and prompt for elevation if not 3498 uac_tryagain: 3499 !insertmacro UAC_RunElevated 3500 StrCpy $Inst_Or_Uninst "$(Uninstaller)" 3501 ${Switch} $0 3502 ${Case} 0 3503 ${IfThen} $1 = 1 ${|} Quit ${|} ;# we are the outer process, the inner process has done its work, we are done 3504 ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;# we are admin, let the show go on 3505 ${If} $1 = 3 ;# RunAs completed successfully, but with a non-admin user 3506 MessageBox mb_IconExclamation|mb_TopMost|mb_SetForeground "$(Msg_UAC_Admin_Retry)" /SD IDNO IDOK uac_tryagain IDNO 0 3507 ${EndIf} 3508 ;# fall-through and die 3509 ${Case} 1223 3510 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(Msg_UAC_Admin_Abort)" 3511 Quit 3512 ${Case} 1062 3513 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(Msg_UAC_Logon_Abort)" 3514 Quit 3515 ${Default} 3516 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(Msg_UAC_No_Elevation)" 3517 Quit 3518 ${EndSwitch} 3519 3520########## from here we can be sure to run with admin privileges ########## 3521 3522 SectionSetText ${UnSecDeleteConfigFolder} $(UnSecDeleteConfigFolder_Text) 3523 3524 ClearErrors 3525 Var /GLOBAL UN_INST_PARAMS 3526 Var /GLOBAL UN_INST_HELP 3527 Var /GLOBAL UN_INST_TYPE 3528 StrCpy $UN_INST_TYPE "" 3529 ${GetParameters} $UN_INST_PARAMS 3530 StrCmp $UN_INST_PARAMS "" no_params 3531 3532 ${GetOptions} "$UN_INST_PARAMS" "/?" $UN_INST_HELP 3533 IfErrors +3 3534 StrCpy $UN_INST_HELP "help" 3535 Goto end 3536 3537 ClearErrors 3538 ${GetOptions} "$UN_INST_PARAMS" "/type" $UN_INST_TYPE 3539 IfErrors no_type_param 3540 ${Switch} $UN_INST_TYPE 3541 ${Case} "=1" ;# 1 = Program Files only (Remove/ Delete: Program Files) 3542 StrCpy $UN_INST_TYPE 1 3543 !insertmacro ClearSectionFlag ${UnSecDeleteConfigFolder} ${SF_SELECTED} 3544 !insertmacro ClearSectionFlag ${UnSecDeleteConfigRegKey} ${SF_SELECTED} 3545 ${Break} 3546 ${Case} "=2" ;# 2 = Preserve Config folder (Remove/ Delete: Program Files + RegKey) 3547 StrCpy $UN_INST_TYPE 2 3548 !insertmacro ClearSectionFlag ${UnSecDeleteConfigFolder} ${SF_SELECTED} 3549 ${Break} 3550 ${Case} "=3" ;# 3 = Preserve RegKey (Remove/ Delete: Program Files + Config folder) 3551 StrCpy $UN_INST_TYPE 3 3552 !insertmacro ClearSectionFlag ${UnSecDeleteConfigRegKey} ${SF_SELECTED} 3553 SectionSetFlags ${UnSecBackupConfigToRegKey} ${SF_SELECTED} 3554 ${Break} 3555 ${Case} "=4" ;# 4 = Delete Config folder (Remove/ Delete: Config folder) 3556 StrCpy $UN_INST_TYPE 4 3557 !insertmacro ClearSectionFlag ${UnSecUninstall} ${SF_SELECTED} 3558 !insertmacro ClearSectionFlag ${UnSecDeleteConfigRegKey} ${SF_SELECTED} 3559 SectionSetFlags ${UnSecBackupConfigToRegKey} ${SF_SELECTED} 3560 ${Break} 3561 ${Case} "=5" ;# 5 = Delete RegKey (Remove/ Delete: RegKey) 3562 StrCpy $UN_INST_TYPE 5 3563 !insertmacro ClearSectionFlag ${UnSecUninstall} ${SF_SELECTED} 3564 !insertmacro ClearSectionFlag ${UnSecDeleteConfigFolder} ${SF_SELECTED} 3565 ${Break} 3566 ${Default} 3567 StrCpy $9 $UN_INST_TYPE 3568 StrCpy $UN_INST_TYPE "error_type" ;# unknown value given for the type parameter => MsgBox => Quit 3569 ${Break} 3570 ${EndSwitch} 3571 3572 StrCmp $UN_INST_TYPE "error_type" 0 cont 3573 MessageBox MB_OK|MB_ICONEXCLAMATION "$(Msg_Unknown_Type_Param)" 3574 Quit 3575 3576 no_type_param: 3577 ;# If no parameter 'type' is given assume full uninstall 3578 StrCpy $UN_INST_TYPE 0 ;# 0 = Full Uninstall (Remove/ Delete: Program Files + Config folder + RegKey) 3579 Goto cont 3580 3581 no_params: 3582 ;# If no parameters are given assume full uninstall 3583 StrCpy $UN_INST_TYPE 0 ;# 0 = Full Uninstall (Remove/ Delete: Program Files + Config folder + RegKey) 3584 3585 cont: 3586 ;# Delete all temporary files created during the installation 3587 Delete "$TEMP\opencpn_*.tmp" 3588 3589 Call un.VersionDate 3590 3591 Call un.Check_Prev_Installs 3592 3593 ;# If there are other installations of OCPN do not remove the config folder! 3594 ${If} $UN_INST_TYPE == 0 3595 ${AndIf} $VERSION_EXISTS == 1 3596 ${AndIf} $MULTIPLE_INSTALLS > 1 3597 StrCpy $Skip_UnPage_Components 1 3598 !insertmacro ClearSectionFlag ${UnSecDeleteConfigFolder} ${SF_SELECTED} 3599 ${EndIf} 3600 3601 ReadRegStr $0 HKLM "${REG_KEY_UN}" "CompareVersion" 3602 3603 end: 3604FunctionEnd 3605 3606 3607Function un.myGuiInit 3608 ${If} $UN_INST_HELP == "help" 3609 MessageBox MB_OK|MB_ICONINFORMATION "$(Msg_Uninstaller_Param_Help)" 3610 Quit 3611 ${EndIf} 3612FunctionEnd 3613 3614;-------------------------------- 3615;################################################################################################## 3616;# Uninstaller Page Functions # 3617;################################################################################################## 3618 ;# UnPage_Components_Pre 3619 Function un.Page_Components_Pre 3620 ${If} $Skip_UnPage_Components == 1 3621 Abort 3622 ${EndIf} 3623 FunctionEnd 3624 3625;-------------------------------- 3626;################################################################################################## 3627;# General Uninstaller Functions # 3628;################################################################################################## 3629 3630 3631 3632;-------------------------------- 3633;################################################################################################## 3634;# Shared Functions # 3635;################################################################################################## 3636!macro GetUserInfo_Macro un 3637 Function ${un}GetUserInfo 3638 ClearErrors 3639 UserInfo::GetName 3640 ${If} ${Errors} 3641 StrCpy $IS_ADMIN 1 3642 Return 3643 ${EndIf} 3644 Pop $USERNAME 3645 3646 UserInfo::GetAccountType 3647 Pop $R0 3648 StrCpy $UAT $R0 3649 ${If} ${IsNT} 3650 ${AndIf} ${IsWinNT4} 3651 ${If} $R0 == "Admin" 3652 StrCpy $IS_ADMIN 1 3653 ${Else} 3654 StrCpy $IS_ADMIN 0 3655 ${EndIf} 3656 Goto end 3657 ${EndIf} 3658 3659 ${Switch} $R0 3660 ${Case} "Admin" 3661 ${Case} "Power" 3662 StrCpy $IS_ADMIN 1 3663 ${Break} 3664 ${Default} 3665 StrCpy $IS_ADMIN 0 3666 ${Break} 3667 ${EndSwitch} 3668 3669 UserInfo::GetOriginalAccountType 3670 Pop $OUAT 3671 3672 end: 3673 FunctionEnd 3674!macroend 3675!insertmacro GetUserInfo_Macro "" 3676!insertmacro GetUserInfo_Macro "un." 3677 3678 3679!macro Check_Prev_Installs_Macro un 3680 Function ${un}Check_Prev_Installs 3681 StrCpy $R0 0 3682 StrCpy $R1 "" 3683 StrCpy $R5 0 3684 StrCpy $VERSION_EXISTS 0 3685 SetShellVarContext all 3686 ${Do} 3687 EnumRegKey $R1 SHCTX "${REG_ROOT_KEY_UN}" $R0 3688 ${If} $R1 != "" 3689 StrLen $R2 $R1 3690 ${WordFind} "$R1" " " "+1" $R3 3691 IntOp $R0 $R0 + 1 3692 ${If} $R3 == "OpenCPN" 3693 ${AndIf} $R2 > 7 3694 ReadRegStr $R4 SHCTX "${REG_ROOT_KEY_UN}\$R1" "CompareVersion" 3695 ReadRegStr $R6 SHCTX "${REG_ROOT_KEY_UN}\$R1" "InstallLocation" 3696 ${If} $R4 != "" 3697 ${VersionCompare} $VERSION_DATE $R4 $Compare_Version_Result 3698 ${Switch} $Compare_Version_Result 3699 ${Case} 0 ;equal 3700 StrCpy $VERSION_EXISTS 1 3701 ${Break} 3702 ${Case} 1 ;version to install is newer 3703 StrCpy $VERSION_NEWER 1 3704 ${Break} 3705 ${Case} 2 ;version to install is older 3706 StrCpy $VERSION_OLDER 1 3707 ${Break} 3708 ${Default} 3709 ${Break} 3710 ${EndSwitch} 3711 IntOp $R5 $R5 + 1 3712 StrCpy $Prev_Install_RegKey "${REG_ROOT_KEY_UN}\$R1" 3713 ${EndIf} 3714 StrCmp ${un} "" 0 uninst ;# only execute when it is the Installer function 3715 ${If} $R6 != "" 3716 ClearErrors 3717 ${If} ${FileExists} "$TEMP\opencpn_prev_installs.tmp" 3718 FileOpen $0 "$TEMP\opencpn_prev_installs.tmp" a 3719 FileSeek $0 0 END 3720 ${Else} 3721 FileOpen $0 "$TEMP\opencpn_prev_installs.tmp" w 3722 ${EndIf} 3723 IfErrors done 3724 FileWriteUTF16LE $0 "$R1$\r$\n" 3725 FileWriteUTF16LE $0 "$R6$\r$\n" 3726 FileClose $0 3727 done: 3728 ${EndIf} 3729 3730 ${If} $VERSION_EXISTS == 1 3731 ${Break} 3732 ${EndIf} 3733 3734 uninst: 3735 ${EndIf} 3736 ${Else} 3737 Goto done2 3738 ${EndIf} 3739 ${Loop} 3740 done2: 3741 ${If} $R5 > 0 3742 StrCpy $MULTIPLE_INSTALLS $R5 3743 ${Else} 3744 StrCpy $MULTIPLE_INSTALLS 0 3745 ${EndIf} 3746 ${If} $MULTIPLE_INSTALLS == 0 3747 StrCpy $Skip_Page_TypeInst 1 3748 ${Else} 3749 StrCpy $Skip_Page_TypeInst 0 3750 ${EndIf} 3751 FunctionEnd 3752!macroend 3753!insertmacro Check_Prev_Installs_Macro "" 3754!insertmacro Check_Prev_Installs_Macro "un." 3755 3756 3757/* VersionDate 3758 normalizes the CPACK_PACKAGE_VERSION_PATCH to a comparable format 'yyyy.[02|19].mmdd.00' 3759 02 = Beta version 3760 19 = Stable release 3761 IN: CPACK_PACKAGE_VERSION_PATCH 3762 OUT: $VERSION_DATE 3763*/ 3764Var Patch_Version 3765Var Version_Digits_Only 3766Var Version_Unified 3767Var Patch_Date 3768!macro VersionDate_Macro un 3769 Function ${un}VersionDate 3770 StrCpy $Patch_Version "@CPACK_PACKAGE_VERSION_PATCH@" 3771 ${If} $Patch_Version == "" 3772 StrCpy $Patch_Version "0000" 3773 ${EndIf} 3774 StrLen $0 "$Patch_Version" 3775 ${StrFilter} "$Patch_Version" "1" "" "" $Version_Digits_Only 3776 StrLen $1 $Version_Digits_Only 3777 ;# Patch version contains non-digit characters 3778 ${If} $0 != $1 3779 ${StrFilter} "$Patch_Version" "-2" "" "" $PATCH_ND 3780 ${If} $1 == 3 3781 StrCpy $Version_Unified "b${YEAR}0$Patch_Version" 3782 ${ElseIf} $1 == 2 3783 StrCpy $Version_Unified "s${YEAR}00$Patch_Version" 3784 ${ElseIf} $1 == 1 3785 StrCpy $Version_Unified "s${YEAR}000$Patch_Version" 3786 ${Else} 3787 StrCpy $Version_Unified "b${YEAR}$Patch_Version" 3788 ${EndIf} 3789 ${VersionConvert} $Version_Unified "" $Patch_Date 3790 StrCpy $VERSION_DATE "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.$Patch_Date" 3791 ;# Patch version contains only digits 3792 ${Else} 3793 ${If} $0 == 3 3794 StrCpy $Version_Unified "b${YEAR}0$Patch_Version" 3795 ${ElseIf} $0 == 2 3796 StrCpy $Version_Unified "s${YEAR}00$Patch_Version" 3797 ${ElseIf} $0 == 1 3798 StrCpy $Version_Unified "s${YEAR}000$Patch_Version" 3799 ${Else} 3800 StrCpy $Version_Unified "b${YEAR}$Patch_Version" 3801 ${EndIf} 3802 ${VersionConvert} $Version_Unified "" $Patch_Date 3803 StrCpy $VERSION_DATE "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.$Patch_Date.00" 3804 ${EndIf} 3805 FunctionEnd 3806!macroend 3807!insertmacro VersionDate_Macro "" 3808!insertmacro VersionDate_Macro "un." 3809 3810 3811!macro Delete_Start_Menu_Shortcuts_Macro un 3812 Function ${un}Delete_Start_Menu_Shortcuts 3813 Pop $9 3814 Push $R0 3815 Push $R1 3816 Push $R2 3817 Push $R3 3818 Push $R4 3819 ${TrimNewLines} $9 $9 3820 SetShellVarContext all 3821 ${RecFindOpen} "$STARTMENU" $CurrentDirVar $CurrentFileVar 3822 ${RecFindFirst} 3823 ClearErrors 3824 ${WordFind} "$CurrentFileVar" ".lnk" "E*" $8 3825 IfErrors next 3826 IntCmp $8 1 0 next 0 3827 ShellLink::GetShortCutWorkingDirectory "$STARTMENU$CurrentDirVar\$CurrentFileVar" 3828 Pop $0 3829 StrCmp "$0" "" +2 3830 StrCmp "$0" "$9" 0 next 3831 ShellLink::GetShortCutTarget "$STARTMENU$CurrentDirVar\$CurrentFileVar" 3832 Pop $1 3833 ${WordFind2X} "$1" "\" ".exe" "-1" $7 3834 ClearErrors 3835 ${WordFind} "$7" "uninstall" "E*" $6 3836 IfErrors 0 +2 3837 StrCpy $6 0 3838 ;#NON-DEBUG 3839 ${If} $7 == "opencpn" 3840 ${OrIf} $7 == "Uninstall" 3841 ${OrIf} $7 == "unins000" 3842 ${OrIf} $6 == 1 3843 Delete "$STARTMENU$CurrentDirVar\$CurrentFileVar" 3844 StrCmp $CurrentDirVar "" next 3845 ClearErrors 3846 RMDir "$STARTMENU$CurrentDirVar" 3847 Sleep 250 3848 IfErrors 0 check_parent 3849 ${If} ${FileExists} "$STARTMENU$CurrentDirVar\*.*" 3850 ClearErrors 3851 RMDir "$STARTMENU$CurrentDirVar" 3852 Sleep 250 3853 IfErrors next check_parent 3854 ${EndIf} 3855 3856 Goto next 3857 3858 check_parent: 3859 StrCpy $R3 "$STARTMENU$CurrentDirVar" 3860 Push $R3 3861 Call ${un}Parent_Dirs_Check 3862 ${EndIf} 3863 3864 next: 3865 ${RecFindNext} 3866 ${RecFindClose} 3867 3868 ${If} ${FileExists} "$TEMP\opencpn_startmenu.tmp" 3869 FileOpen $R0 "$TEMP\opencpn_startmenu.tmp" r 3870 IfErrors end 3871 ${Do} 3872 FileReadUTF16LE $R0 $R1 3873 FileReadUTF16LE $R0 $R2 3874 ${TrimNewLines} $R1 $R1 3875 ${TrimNewLines} $R2 $R2 3876 StrCmp $R2 "" 0 +2 3877 ${Break} 3878 ${RecFindOpen} "$R2" $CurrentDirVar $CurrentFileVar 3879 ${RecFindFirst} 3880 ClearErrors 3881 ${WordFind} "$CurrentFileVar" ".lnk" "E*" $8 3882 IfErrors next1 3883 IntCmp $8 1 0 next1 0 3884 ShellLink::GetShortCutWorkingDirectory "$R2$CurrentDirVar\$CurrentFileVar" 3885 Pop $0 3886 StrCmp "$0" "$9" 0 next1 3887 ShellLink::GetShortCutTarget "$R2$CurrentDirVar\$CurrentFileVar" 3888 Pop $1 3889 ${WordFind2X} "$1" "\" ".exe" "-1" $7 3890 ;#NON-DEBUG 3891 ${If} $7 == "opencpn" 3892 ${OrIf} $7 == "Uninstall" 3893 ${OrIf} $7 == "unins000" 3894 Delete "$R2$CurrentDirVar\$CurrentFileVar" 3895 StrCmp $CurrentDirVar "" next1 3896 ClearErrors 3897 RMDir "$R2$CurrentDirVar" 3898 Sleep 250 3899 IfErrors 0 check_parent1 3900 ${If} ${FileExists} "$R2$CurrentDirVar\*.*" 3901 ClearErrors 3902 RMDir "$R2$CurrentDirVar" 3903 Sleep 250 3904 IfErrors next1 check_parent1 3905 ${EndIf} 3906 3907 Goto next1 3908 3909 check_parent1: 3910 StrCpy $R3 "$STARTMENU$CurrentDirVar" 3911 Push $R3 3912 Call ${un}Parent_Dirs_Check 3913 ${EndIf} 3914 3915 next1: 3916 ${RecFindNext} 3917 ${RecFindClose} 3918 ${LoopUntil} $R2 == "" 3919 FileClose $R0 3920 ${EndIf} 3921 3922 end: 3923 Call ${un}Delete_Empty_Parents 3924 3925 Pop $R4 3926 Pop $R3 3927 Pop $R2 3928 Pop $R1 3929 Pop $R0 3930 FunctionEnd 3931!macroend 3932!insertmacro Delete_Start_Menu_Shortcuts_Macro "" 3933!insertmacro Delete_Start_Menu_Shortcuts_Macro "un." 3934 3935 3936!macro Delete_Desktop_Shortcuts_Macro un 3937 Function ${un}Delete_Desktop_Shortcuts 3938 Pop $9 3939 Push $R0 3940 Push $R1 3941 Push $R2 3942 Push $R3 3943 ${TrimNewLines} $9 $9 3944 SetShellVarContext all 3945 ${RecFindOpen} "$DESKTOP" $CurrentDirVar $CurrentFileVar 3946 ${RecFindFirst} 3947 ClearErrors 3948 ${WordFind} "$CurrentFileVar" ".lnk" "E*" $8 3949 IfErrors next 3950 IntCmp $8 1 0 next 0 3951 ShellLink::GetShortCutWorkingDirectory "$DESKTOP$CurrentDirVar\$CurrentFileVar" 3952 Pop $0 3953 StrCmp "$0" "" +2 3954 StrCmp "$0" "$9" 0 next 3955 ShellLink::GetShortCutTarget "$DESKTOP$CurrentDirVar\$CurrentFileVar" 3956 Pop $1 3957 ${WordFind2X} "$1" "\" ".exe" "-1" $7 3958 ClearErrors 3959 ${WordFind} "$7" "uninstall" "E*" $6 3960 IfErrors 0 +2 3961 StrCpy $6 0 3962 ;#NON-DEBUG 3963 ${If} $7 == "opencpn" 3964 ${OrIf} $7 == "Uninstall" 3965 ${OrIf} $7 == "unins000" 3966 ${OrIf} $6 == 1 3967 Delete "$DESKTOP$CurrentDirVar\$CurrentFileVar" 3968 StrCmp $CurrentDirVar "" next 3969 RMDir "$DESKTOP$CurrentDirVar" 3970 Sleep 250 3971 IfErrors 0 check_parent 3972 ${If} ${FileExists} "$DESKTOP$CurrentDirVar\*.*" 3973 ClearErrors 3974 RMDir "$DESKTOP$CurrentDirVar" 3975 Sleep 250 3976 IfErrors next check_parent 3977 ${EndIf} 3978 3979 Goto next 3980 3981 check_parent: 3982 StrCpy $R3 "$DESKTOP$CurrentDirVar" 3983 Push $R3 3984 Call ${un}Parent_Dirs_Check 3985 ${EndIf} 3986 3987 next: 3988 ${RecFindNext} 3989 ${RecFindClose} 3990 3991 ${If} ${FileExists} "$TEMP\opencpn_desktop.tmp" 3992 FileOpen $R0 "$TEMP\opencpn_desktop.tmp" r 3993 IfErrors end 3994 ${Do} 3995 FileReadUTF16LE $R0 $R1 3996 FileReadUTF16LE $R0 $R2 3997 ${TrimNewLines} $R1 $R1 3998 ${TrimNewLines} $R2 $R2 3999 StrCmp $R2 "" 0 +2 4000 ${Break} 4001 ${RecFindOpen} "$R2" $CurrentDirVar $CurrentFileVar 4002 ${RecFindFirst} 4003 ClearErrors 4004 ${WordFind} "$CurrentFileVar" ".lnk" "E*" $8 4005 IfErrors next1 4006 IntCmp $8 1 0 next1 0 4007 ShellLink::GetShortCutWorkingDirectory "$R2$CurrentDirVar\$CurrentFileVar" 4008 Pop $0 4009 StrCmp "$0" "$9" 0 next1 4010 ShellLink::GetShortCutTarget "$R2$CurrentDirVar\$CurrentFileVar" 4011 Pop $1 4012 ${WordFind2X} "$1" "\" ".exe" "-1" $7 4013 ;#NON-DEBUG 4014 ${If} $7 == "opencpn" 4015 ${OrIf} $7 == "Uninstall" 4016 ${OrIf} $7 == "unins000" 4017 Delete "$R2$CurrentDirVar\$CurrentFileVar" 4018 StrCmp $CurrentDirVar "" next1 4019 RMDir "$R2$CurrentDirVar" 4020 Sleep 250 4021 IfErrors 0 check_parent1 4022 ${If} ${FileExists} "$R2$CurrentDirVar\*.*" 4023 ClearErrors 4024 RMDir "$R2$CurrentDirVar" 4025 Sleep 250 4026 IfErrors next1 check_parent1 4027 ${EndIf} 4028 4029 Goto next1 4030 4031 check_parent1: 4032 StrCpy $R3 "$STARTMENU$CurrentDirVar" 4033 Push $R3 4034 Call ${un}Parent_Dirs_Check 4035 ${EndIf} 4036 4037 next1: 4038 ${RecFindNext} 4039 ${RecFindClose} 4040 ${LoopUntil} $R2 == "" 4041 FileClose $R0 4042 ${EndIf} 4043 4044 end: 4045 Call ${un}Delete_Empty_Parents 4046 4047 Pop $R3 4048 Pop $R2 4049 Pop $R1 4050 Pop $R0 4051 FunctionEnd 4052!macroend 4053!insertmacro Delete_Desktop_Shortcuts_Macro "" 4054!insertmacro Delete_Desktop_Shortcuts_Macro "un." 4055 4056 4057!macro Parent_Dirs_Check_Macro un 4058 Function ${un}Parent_Dirs_Check 4059 Pop $R3 4060 Push $R4 4061 ClearErrors 4062 ${If} ${FileExists} "$TEMP\opencpn_check_parent.tmp" 4063 FileOpen $R4 "$TEMP\opencpn_check_parent.tmp" a 4064 IfErrors end 4065 ${Else} 4066 FileOpen $R4 "$TEMP\opencpn_check_parent.tmp" w 4067 IfErrors end 4068 ${EndIf} 4069 4070 ${WordFind} "$R3" "\" "E-2{*" $R3 4071 IfErrors close 4072 FileWriteUTF16LE $R4 "$R3$\r$\n" 4073 4074 close: 4075 FileClose $R4 4076 4077 end: 4078 Pop $R4 4079 FunctionEnd 4080!macroend 4081!insertmacro Parent_Dirs_Check_Macro "" 4082!insertmacro Parent_Dirs_Check_Macro "un." 4083 4084 4085!macro Delete_Empty_Parents_Macro un 4086 Function ${un}Delete_Empty_Parents 4087 Push $R3 4088 Push $R4 4089 Push $R5 4090 ClearErrors 4091 ${If} ${FileExists} "$TEMP\opencpn_check_parent.tmp" 4092 FileOpen $R4 "$TEMP\opencpn_check_parent.tmp" r 4093 IfErrors end 4094 ${Do} 4095 FileReadUTF16LE $R4 $R3 4096 IfErrors close 4097 ${TrimNewLines} "$R3" $R3 4098 ${DirState} $R3 $R5 4099 StrCmp $R5 0 0 next 4100 ClearErrors 4101 RMDir "$R3" 4102 Sleep 250 4103 IfErrors next 4104 4105 loop: 4106 ${WordFind} "$R3" "\" "E-2{*" $R3 4107 IfErrors next 4108 StrCpy $error_tmp 0 4109 Push $R3 4110 Call ${un}Delete_Empty_Dir 4111 StrCmp $error_tmp 1 loop 4112 next: 4113 ${Loop} 4114 close: 4115 FileClose $R4 4116 Delete "$TEMP\opencpn_check_parent.tmp" 4117 ${EndIf} 4118 end: 4119 Pop $R5 4120 Pop $R4 4121 Pop $R3 4122 FunctionEnd 4123!macroend 4124!insertmacro Delete_Empty_Parents_Macro "" 4125!insertmacro Delete_Empty_Parents_Macro "un." 4126 4127 4128!macro Delete_Empty_Dir_Macro un 4129 Function ${un}Delete_Empty_Dir 4130 Push $R3 4131 Exch 4132 Pop $R3 4133 Push $R4 4134 ${DirState} $R3 $R4 4135 StrCmp $R4 0 0 end 4136 RMDir "$R3" 4137 Sleep 100 4138 StrCpy $error_tmp 1 4139 4140 end: 4141 Pop $R4 4142 Pop $R3 4143 FunctionEnd 4144!macroend 4145!insertmacro Delete_Empty_Dir_Macro "" 4146!insertmacro Delete_Empty_Dir_Macro "un." 4147 4148 4149; Initialize variables 4150Var explString 4151Var explSeparator 4152Var explStrLen 4153Var explSepLen 4154Var explOffset 4155Var explTmp 4156Var explTmp2 4157Var explTmp3 4158Var explArrCount 4159!macro Explodes_Macro un 4160 Function ${un}Explode 4161 /*; Initialize variables 4162 Var /GLOBAL explString 4163 Var /GLOBAL explSeparator 4164 Var /GLOBAL explStrLen 4165 Var /GLOBAL explSepLen 4166 Var /GLOBAL explOffset 4167 Var /GLOBAL explTmp 4168 Var /GLOBAL explTmp2 4169 Var /GLOBAL explTmp3 4170 Var /GLOBAL explArrCount 4171 */ 4172 ; Get input from user 4173 Pop $explString 4174 Pop $explSeparator 4175 4176 ; Calculates initial values 4177 StrLen $explStrLen $explString 4178 StrLen $explSepLen $explSeparator 4179 StrCpy $explArrCount 1 4180 4181 ${If} $explStrLen <= 1 ; If we got a single character 4182 ${OrIf} $explSepLen > $explStrLen ; or separator is larger than the string, 4183 Push $explString ; then we return initial string with no change 4184 Push 1 ; and set array's length to 1 4185 Return 4186 ${EndIf} 4187 4188 ; Set offset to the last symbol of the string 4189 StrCpy $explOffset $explStrLen 4190 IntOp $explOffset $explOffset - 1 4191 4192 ; Clear temp string to exclude the possibility of appearance of occasional data 4193 StrCpy $explTmp "" 4194 StrCpy $explTmp2 "" 4195 StrCpy $explTmp3 "" 4196 4197 ; Loop until the offset becomes negative 4198 ${Do} 4199 ; If offset becomes negative, it is time to leave the function 4200 ${IfThen} $explOffset == -1 ${|} ${ExitDo} ${|} 4201 4202 ; Remove everything before and after the searched part ("TempStr") 4203 StrCpy $explTmp $explString $explSepLen $explOffset 4204 4205 ${If} $explTmp == $explSeparator 4206 ; Calculating offset to start copy from 4207 IntOp $explTmp2 $explOffset + $explSepLen ; Offset equals to the current offset plus length of separator 4208 StrCpy $explTmp3 $explString "" $explTmp2 4209 4210 Push $explTmp3 ; Throwing array item to the stack 4211 IntOp $explArrCount $explArrCount + 1 ; Increasing array's counter 4212 4213 StrCpy $explString $explString $explOffset 0 ; Cutting all characters beginning with the separator entry 4214 StrLen $explStrLen $explString 4215 ${EndIf} 4216 4217 ${If} $explOffset = 0 ; If the beginning of the line met and there is no separator, 4218 ; copying the rest of the string 4219 ${If} $explSeparator == "" ; Fix for the empty separator 4220 IntOp $explArrCount $explArrCount - 1 4221 ${Else} 4222 Push $explString 4223 ${EndIf} 4224 ${EndIf} 4225 4226 IntOp $explOffset $explOffset - 1 4227 ${Loop} 4228 4229 Push $explArrCount 4230 FunctionEnd 4231!macroend 4232!insertmacro Explodes_Macro "" 4233!insertmacro Explodes_Macro "un." 4234 4235 4236!macro isEmptyDir_Macro un 4237 Function ${un}isEmptyDir 4238 # Stack -> # Stack: <directory> 4239 Exch $0 # Stack: $0 4240 Push $1 # Stack: $1, $0 4241 FindFirst $0 $1 "$0\*.*" 4242 StrCmp $1 "." 0 _notempty 4243 FindNext $0 $1 4244 StrCmp $1 ".." 0 _notempty 4245 ClearErrors 4246 FindNext $0 $1 4247 IfErrors 0 _notempty 4248 FindClose $0 4249 Pop $1 # Stack: $0 4250 StrCpy $0 1 4251 Exch $0 # Stack: 1 (true) 4252 Goto _end 4253 _notempty: 4254 FindClose $0 4255 Pop $1 # Stack: $0 4256 StrCpy $0 0 4257 Exch $0 # Stack: 0 (false) 4258 _end: 4259 FunctionEnd 4260!macroend 4261!insertmacro isEmptyDir_Macro "" 4262!insertmacro isEmptyDir_Macro "un." 4263;-------------------------------------------------------------------------------------------------- 4264;################################################################################################## 4265;# D E S C R I P T I O N S # 4266;################################################################################################## 4267;# Installer Descriptions # 4268;################################################################################################## 4269 4270;# License page 4271 LicenseLangString license ${LANG_ENGLISH} "@CPACK_RESOURCE_FILE_LICENSE@" 4272 LicenseLangString license ${LANG_GERMAN} "@CPACK_RESOURCE_FILE_LICENSE@" 4273 LicenseLangString license ${LANG_FRENCH} "@CPACK_RESOURCE_FILE_LICENSE@" 4274 LicenseLangString license ${LANG_CZECH} "@CPACK_RESOURCE_FILE_LICENSE@" 4275 LicenseLangString license ${LANG_DANISH} "@CPACK_RESOURCE_FILE_LICENSE@" 4276 LicenseLangString license ${LANG_SPANISH} "@CPACK_RESOURCE_FILE_LICENSE@" 4277 LicenseLangString license ${LANG_ITALIAN} "@CPACK_RESOURCE_FILE_LICENSE@" 4278 LicenseLangString license ${LANG_DUTCH} "@CPACK_RESOURCE_FILE_LICENSE@" 4279 LicenseLangString license ${LANG_POLISH} "@CPACK_RESOURCE_FILE_LICENSE@" 4280 LicenseLangString license ${LANG_PORTUGUESE} "@CPACK_RESOURCE_FILE_LICENSE@" 4281 LicenseLangString license ${LANG_PORTUGUESEBR} "@CPACK_RESOURCE_FILE_LICENSE@" 4282 LicenseLangString license ${LANG_RUSSIAN} "@CPACK_RESOURCE_FILE_LICENSE@" 4283 LicenseLangString license ${LANG_SWEDISH} "@CPACK_RESOURCE_FILE_LICENSE@" 4284 LicenseLangString license ${LANG_FINNISH} "@CPACK_RESOURCE_FILE_LICENSE@" 4285 LicenseLangString license ${LANG_NORWEGIAN} "@CPACK_RESOURCE_FILE_LICENSE@" 4286 LicenseLangString license ${LANG_TRADCHINESE} "@CPACK_RESOURCE_FILE_LICENSE@" 4287 LicenseLangString license ${LANG_TURKISH} "@CPACK_RESOURCE_FILE_LICENSE@" 4288 ;LicenseLangString license ${LANG_HUNGARIAN} "@CPACK_RESOURCE_FILE_LICENSE@" 4289 4290!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN 4291 !insertmacro MUI_DESCRIPTION_TEXT ${SecGrpResetConfig} $(SecGrpResetConfig_Desc) 4292 !insertmacro MUI_DESCRIPTION_TEXT ${SecDeleteConfigFile} $(SecDeleteConfigFile_Desc) 4293 !insertmacro MUI_DESCRIPTION_TEXT ${SecDeleteChartDB} $(SecDeleteChartDB_Desc) 4294 !insertmacro MUI_DESCRIPTION_TEXT ${SecDeleteSENC} $(SecDeleteSENC_Desc) 4295 !insertmacro MUI_DESCRIPTION_TEXT ${SecDeleteCM93} $(SecDeleteCM93_Desc) 4296 !insertmacro MUI_DESCRIPTION_TEXT ${SecDeleteNavobjFile} $(SecDeleteNavobjFile_Desc) 4297 !insertmacro MUI_DESCRIPTION_TEXT ${SecDeleteLogFile} $(SecDeleteLogFile_Desc) 4298 !insertmacro MUI_DESCRIPTION_TEXT ${SecGrpShortcuts} $(SecGrpShortcuts_Desc) 4299 !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcutStartmenu} $(SecShortcutStartmenu_Desc) 4300 !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcutDesktop} $(SecShortcutDesktop_Desc) 4301 !insertmacro MUI_DESCRIPTION_TEXT ${SecSetConfig} $(SecSetConfig_Desc) 4302!insertmacro MUI_FUNCTION_DESCRIPTION_END 4303 4304;-------------------------------- 4305;################################################################################################## 4306;# Uninstaller Descriptions # 4307;################################################################################################## 4308!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN 4309 !insertmacro MUI_DESCRIPTION_TEXT ${UnSecDeleteConfigFolder} $(UnSecDeleteConfigFolder_Desc) 4310!insertmacro MUI_UNFUNCTION_DESCRIPTION_END 4311 4312 4313;-------------------------------------------------------------------------------------------------- 4314;################################################################################################## 4315;# Language Strings # 4316;################################################################################################## 4317;#DO NOT EDIT THE NEXT LINE!!! It is needed for the online generating of the translation files! 4318;#Language Strings Start as of: 2010-10-10 4319;#IMPORTANT: Do not end a multi-line with $\" 4320 4321 LangString Installer ${LANG_ENGLISH} "installer" 4322 4323 LangString Uninstaller ${LANG_ENGLISH} "uninstaller" 4324 4325 ;Installer running on unsupported version of Windows 4326 LangString Installer_Unsupported_Windows_Version ${LANG_ENGLISH} "Your Windows version is not supported (it's too old)!$\r$\nYou need at least Windows XP SP3." 4327 4328 ;Installer running on Windows XP without SP3 4329 LangString Installer_Unsupported_XP_SP_Version ${LANG_ENGLISH} "Your Windows XP Service Pack version is not supported (it's too old)!$\r$\nYou need at least Windows XP SP3." 4330 4331 ;Installer already running 4332 LangString Installer_Running ${LANG_ENGLISH} "The installer is already running." 4333 4334 ;Uninstaller already running 4335 LangString Uninstaller_Running ${LANG_ENGLISH} "The uninstaller is already running." 4336 4337 ;Language Dialog 4338 LangString LangDialog_Title ${LANG_ENGLISH} "@CPACK_PACKAGE_NAME@ @CPACK_PACKAGE_VERSION@ Installation" 4339 4340 LangString LangDialog_Text ${LANG_ENGLISH} "Please select a language:" 4341 4342 ;License dialog 4343 LangString License_Message ${LANG_ENGLISH} "OpenCPN is software libre. You are encouraged and legally \ 4344 entitled to copy, reinstall, modify, and redistribute this program \ 4345 for yourself and your friends under the terms of the GPL. $\r$\nSmooth sailing!" 4346 4347 ;Clean up page 4348 LangString text_please_wait_1 ${LANG_ENGLISH} "... please wait!" 4349 4350 LangString Scanning_HDD ${LANG_ENGLISH} "Scanning HDD ..." 4351 4352 LangString OCPN_Scanning_HDD ${LANG_ENGLISH} "OpenCPN: Scan HDD ..., please wait!" 4353 4354 LangString Search_old_installations ${LANG_ENGLISH} "Searching for old installations" 4355 4356 LangString Install_Location_Default ${LANG_ENGLISH} "Install Locations by default paths (may not find all)" 4357 4358 LangString Install_Location_HDD_Scan ${LANG_ENGLISH} "Install Location by full HDD scan (most reliable)" 4359 4360 LangString Label_CleanUp_Text ${LANG_ENGLISH} "Click on a list-item to select/ unselect it or Select ALL (recommended) and then Uninstall selected." 4361 4362 LangString BT_Uninstall_Selected_CleanUp ${LANG_ENGLISH} "Uninstall Selected" 4363 4364 LangString BT_SelectAll_CleanUp ${LANG_ENGLISH} "Select ALL" 4365 4366 LangString BT_UnselectAll_CleanUp ${LANG_ENGLISH} "Unselect ALL" 4367 4368 LangString LB_CleanUp ${LANG_ENGLISH} "Listbox Text" 4369 4370 LangString BT_FullScan_CleanUp ${LANG_ENGLISH} "Scan HDD ..." 4371 4372 LangString LAB_FullScan_CleanUp ${LANG_ENGLISH} "Scan the HDD for the most reliable detection.$\r$\nATTENTION: may last several minutes!" 4373 4374 LangString Page_CleanUp_Title ${LANG_ENGLISH} "Uninstall older Version" 4375 4376 LangString Page_CleanUp_Subtitle ${LANG_ENGLISH} "Incompatible version detected" 4377 4378 ;Components Page 4379 ;Header 4380 LangString CP_HEADER_TEXT ${LANG_ENGLISH} "Installation Settings" 4381 4382 ;Subheader 4383 LangString CP_HEADER_SUBTEXT ${LANG_ENGLISH} "Choose the settings for the installation" 4384 4385 ;Top 4386 LangString CP_TOP ${LANG_ENGLISH} "Check or uncheck the options for the installation.$\r$\nClick 'Next' to continue." 4387 4388 ;Installation type 4389 LangString CP_INSTTYPE ${LANG_ENGLISH} "Installation type:" 4390 4391 ;Components list 4392 LangString CP_COMPLIST ${LANG_ENGLISH} "Adjust the settings individually:" 4393 4394 4395 ;Directory page 4396 4397 4398 ;Set Config page 4399 LangString Page_SetConfig_Title ${LANG_ENGLISH} "Default configuration settings" 4400 4401 LangString Page_SetConfig_Subtitle ${LANG_ENGLISH} "Preconfigure settings for OpenCPN" 4402 4403 LangString Select_Chart_Directory ${LANG_ENGLISH} "Please select a chart directory to add to OpenCPN" 4404 4405 LangString BT_Browse_SetConfig_Text ${LANG_ENGLISH} "Browse..." 4406 4407 LangString BT_DeleteAll_SetConfig_Text ${LANG_ENGLISH} "Delete ALL" 4408 4409 LangString BT_Delete_SetConfig_Text ${LANG_ENGLISH} "Delete" 4410 4411 LangString GB_ChartDir_SetConfig_Text ${LANG_ENGLISH} "Add Chart Directory" 4412 4413 LangString CB_Language_SetConfig_Text ${LANG_ENGLISH} "Set OpenCPN program language to $LANG_NAME" 4414 4415 LangString GB_Language_SetConfig_Text ${LANG_ENGLISH} "Set OpenCPN program language" 4416 4417 LangString Label_SetConfig_Text ${LANG_ENGLISH} "Configure preconfig settings for the OpenCPN program.$\r$\nThese settings are saved in the file opencpn.ini." 4418 4419 ;Confirm page 4420 LangString Page_Confirm_Title ${LANG_ENGLISH} "Ready to Install" 4421 4422 LangString Page_Confirm_Subtitle ${LANG_ENGLISH} "Check the installation options" 4423 4424 LangString Installation_Type ${LANG_ENGLISH} "Setup type" 4425 4426 LangString Installation_Directory ${LANG_ENGLISH} "Destination location" 4427 4428 LangString Create_Shortcuts ${LANG_ENGLISH} "Create shortcuts" 4429 4430 LangString Type_Reinstall ${LANG_ENGLISH} "Reinstallation" 4431 4432 LangString Type_Upgrade ${LANG_ENGLISH} "Upgrade" 4433 4434 LangString Type_Downgrade ${LANG_ENGLISH} "Downgrade" 4435 4436 LangString Type_Parallel_Installation ${LANG_ENGLISH} "Parallel installation" 4437 4438 LangString Type_Fresh_Installation ${LANG_ENGLISH} "New installation" 4439 4440 LangString Shortcuts ${LANG_ENGLISH} "Shortcuts" 4441 4442 LangString Create_Shortcut_Start_Menu ${LANG_ENGLISH} "in the Start Menu folder" 4443 4444 LangString Create_Shortcut_Desktop ${LANG_ENGLISH} "on the Desktop" 4445 4446 LangString not_selected ${LANG_ENGLISH} "not selected" 4447 4448 LangString text_none ${LANG_ENGLISH} "none" 4449 4450 ;Installer Sections 4451 ;Reset config 4452 LangString SecGrpResetConfig_Text ${LANG_ENGLISH} "Reset ALL OpenCPN configuration files" 4453 4454 ;Delete Config file (opencpn.ini) 4455 LangString SecDeleteConfigFile_Text ${LANG_ENGLISH} "Delete config file (opencpn.ini)" 4456 4457 ;Delete Chart DB (CHRTLIST.DAT) 4458 LangString SecDeleteChartDB_Text ${LANG_ENGLISH} "Delete Chart Database file (CHRTLIST.DAT)" 4459 4460 ;Delete SENC directory 4461 LangString SecDeleteSENC_Text ${LANG_ENGLISH} "Delete SENC directory" 4462 4463 ;Delete CM93 directory 4464 LangString SecDeleteCM93_Text ${LANG_ENGLISH} "Delete CM93 Directory" 4465 4466 ;Delete Log file (opencpn.log) 4467 LangString SecDeleteLogFile_Text ${LANG_ENGLISH} "Delete Log file (opencpn.log)" 4468 4469 ;Delete navobj.xml 4470 LangString SecDeleteNavobjFile_Text ${LANG_ENGLISH} "Delete Navobject file (navobj.xml)" 4471 4472 ;Set config 4473 LangString SecSetConfig_Text ${LANG_ENGLISH} "OpenCPN Configuration Settings" 4474 4475 ;Set language 4476 LangString SecSetConfigLang_Text ${LANG_ENGLISH} "Set language to $LANG_NAME" 4477 4478 ;Set chart dir(s) 4479 LangString SecSetConfigChartDir_Text ${LANG_ENGLISH} "Select Chart Directories" 4480 4481 ;Uninstaller Sections 4482 ;Reset config 4483 LangString UnSecDeleteConfigFolder_Text ${LANG_ENGLISH} "Delete Config folder" 4484 4485 ;Installer Descriptions 4486 LangString SecGrpResetConfig_Desc ${LANG_ENGLISH} "Deletes ALL files and subdirectories in the configuration folder." 4487 4488 LangString SecDeleteConfigFile_Desc ${LANG_ENGLISH} "Deletes the configuration file. This file helds also Routes and Waypoints." 4489 4490 LangString SecDeleteChartDB_Desc ${LANG_ENGLISH} "Deletes the Chart DB file." 4491 4492 LangString SecDeleteSENC_Desc ${LANG_ENGLISH} "Deletes the SENC subfolder which helds the Bitmaps and S57 chart cache files." 4493 4494 LangString SecDeleteCM93_Desc ${LANG_ENGLISH} "Deletes the cm93 subfolder which helds the cached cm93 chart outlines." 4495 4496 LangString SecDeleteNavobjFile_Desc ${LANG_ENGLISH} "Deletes the file 'navobj.xml' in the config folder. This file contains the Tracks." 4497 4498 LangString SecDeleteLogFile_Desc ${LANG_ENGLISH} "Deletes the OpenCPN log file 'opencpn.log'." 4499 4500 LangString SecGrpShortcuts_Desc ${LANG_ENGLISH} "Creates shortcuts in both, the Start Menu and on the Desktop." 4501 4502 LangString SecShortcutStartmenu_Desc ${LANG_ENGLISH} "Creates shortcuts for OpenCPN and the Uninstaller in the Start Menu - configurable on the next page." 4503 4504 LangString SecShortcutDesktop_Desc ${LANG_ENGLISH} "Creates a shortcut for OpenCPN on the Desktop." 4505 4506 LangString SecSetConfig_Desc ${LANG_ENGLISH} "Preconfigure the language setting and the chart dir(s) for OpenCPN. When selected a separate page is shown for configuration." 4507 4508 ;Uninstaller Descriptions 4509 LangString UnSecDeleteConfigFolder_Desc ${LANG_ENGLISH} "Deletes the config folder and all its files and subdirectories." 4510 4511 ;Un-install Link 4512 LangString Uninstall_Link ${LANG_ENGLISH} "Uninstall @CPACK_PACKAGE_NAME@ @CPACK_PACKAGE_VERSION@" 4513 4514 ;Multiple Install > 1 4515 ;Title 4516 LangString Page_TypeInst_Title ${LANG_ENGLISH} "Previous Installations" 4517 4518 ;Subtitle 4519 LangString Page_TypeInst_Subtitle ${LANG_ENGLISH} "$MULTIPLE_INSTALLS installations of OpenCPN found.$\r$\nChoose how you want to install OpenCPN." 4520 4521 ;Multiple Install = 1 4522 ;Title 4523 LangString Page_TypeInst_Title_1 ${LANG_ENGLISH} "Already Installed" 4524 4525 ;Subtitle 4526 LangString Page_TypeInst_Subtitle_1 ${LANG_ENGLISH} "Found installed version of OpenCPN.$\r$\nChoose how you want to install OpenCPN." 4527 4528 ;Version exists 4529 ;Title 4530 LangString Page_TypeInst_Title_Exists ${LANG_ENGLISH} "Version Already Installed" 4531 4532 ;Subtitle 4533 LangString Page_TypeInst_Subtitle_Exists ${LANG_ENGLISH} "OpenCPN @CPACK_PACKAGE_VERSION@ is already installed.$\r$\nChoose how you want to install OpenCPN." 4534 4535 ;Label 4536 LangString Label_TypeInst_Reinstall_Text ${LANG_ENGLISH} "OpenCPN @CPACK_PACKAGE_VERSION@ is already installed on your system. You can reinstall the version now using the previous settings. If you wish to install the program with different settings, cancel installation and un-install the existing version first. Click Next to continue." 4537 4538 ;Radio button 'Reinstall' 4539 LangString RB_Reinstall_TypeInst_Text ${LANG_ENGLISH} "Reinstall using previous settings" 4540 4541 ;Version newer 4542 ;Label 4543 LangString Label_TypeInst_Upgrade_Text ${LANG_ENGLISH} "An older version of OpenCPN is installed on your system. Select the installation type you want to perform and click Next to continue." 4544 4545 ;Radio button 'Upgrade' 4546 LangString RB_Upgrade_TypeInst_Text ${LANG_ENGLISH} "Upgrade OpenCPN using previous settings (recommended)" 4547 4548 ;Version older 4549 ;Label 4550 LangString Label_TypeInst_Downgrade_Text ${LANG_ENGLISH} "A newer version of OpenCPN is installed on your system. It is not recommended to downgrade to an older version. Select the installation type you want to perform and click Next to continue." 4551 4552 ;Radio button 'Downgrade' 4553 LangString RB_Downgrade_TypeInst_Text ${LANG_ENGLISH} "Downgrade OpenCPN using previous settings (recommended)" 4554 4555 ;Multiple versions 4556 ;Label 4557 LangString Label_TypeInst_Parallel_Text ${LANG_ENGLISH} "Setup has detected several installed versions of OpenCPN on your system. It is recommended to have only one version of OpenCPN installed at a time. Select the operation you want to perform and click Next to continue." 4558 4559 ;Radio button 'Parallel Installation' 4560 LangString RB_Parallel_TypeInst_Text ${LANG_ENGLISH} "Parallel Installation (advanced users)" 4561 4562 ;Empty string - needed for Components page 4563 LangString EmptyString ${LANG_ENGLISH} "" 4564 4565 ;Finish page 4566 LangString Show_Readme_Text ${LANG_ENGLISH} "Show Install Log file" 4567 4568 LangString Finish_Link_Text ${LANG_ENGLISH} "OpenCPN website (Internet connection required)" 4569 4570 LangString Finish_Link_URL ${LANG_ENGLISH} "http://opencpn.info/?ref=installer&user=$USERS_NAME&lang=$REG_LANG&version=@CPACK_PACKAGE_VERSION@" 4571 4572 ;Message Boxes 4573 LangString Msg_UAC_Admin_Retry ${LANG_ENGLISH} "This $Inst_Or_Uninst requires admin access!$\r$\nPlease log on as an Administrator and try again." 4574 4575 LangString Msg_UAC_Admin_Abort ${LANG_ENGLISH} "This $Inst_Or_Uninst requires admin privileges, aborting!" 4576 4577 LangString Msg_UAC_Logon_Abort ${LANG_ENGLISH} "Logon service not running, aborting!" 4578 4579 LangString Msg_UAC_No_Elevation ${LANG_ENGLISH} "Unable to elevate , error $0" 4580 4581 LangString Msg_Error_Remove_InstDir ${LANG_ENGLISH} "The installation directory$\r$\n'$INSTDIR'$\r$\ncould not be removed because it is not empty." 4582 4583 LangString Msg_Path_Invalid ${LANG_ENGLISH} "The entered path is invalid!$\r$\n$\r$\nPlease check your input." 4584 4585 LangString Msg_Path_Installation_Exists ${LANG_ENGLISH} "There already exists an installation of OpenCPN in the given path.$\r$\nIf you wish to use this path, first uninstall the version. Or select another path for this installation." 4586 4587 LangString Msg_Uninstall_Old_Versions ${LANG_ENGLISH} "Setup has detected at least one older version of OpenCPN which is not compatible with the new version control.$\r$\n\ 4588 It is recommended to first uninstall all of these installations (this does not affect your Config files) and clean-up the Registry.$\r$\n\ 4589 If you click Yes on the next page a listbox with all installation locations will be shown and you will have the possibility to select the installations you wish to uninstall.$\r$\n\ 4590 If you are unsure about possible other previous installations than those shown in the listbox, you can also perform a scan of the entire \ 4591 Harddisk (ATTENTION: This may take several minutes) to find all install locations (recommended).$\r$\n$\r$\n\ 4592 Do you want to uninstall the old version(s)?" 4593 4594 LangString Msg_Not_All_Old_Uninstalled ${LANG_ENGLISH} "You have not uninstalled all previous installations.$\r$\n$\r$\nDo you want to continue anyway?" 4595 4596 LangString Msg_Uninstaller_Param_Help ${LANG_ENGLISH} "Uninstaller Help$\r$\n$\r$\nUse the command line or a shortcut to run the uninstaller:$\r$\n$INSTDIR\Uninstall @CPACK_PACKAGE_VERSION@.exe [/?] | [/S], [/type=X]$\r$\n$\r$\nParameters:$\r$\n/?$\tshows this help message box$\r$\n/S$\truns the uninstaller in silent mode$\r$\n$\twill do a full uninstall if called without any type parameter$\r$\n/type=X$\tX must be a digit between 1 and 5$\r$\n$\t1 = Removes only the program files$\r$\n$\t2 = Removes only the program files + preconfig RegKey$\r$\n$\t3 = Removes the program files + config folder$\r$\n$\tpreserves the preconfig RegKey$\r$\n$\t4 = Deletes only the config folder$\r$\n$\t5 = Deletes only the preconfig RegKey$\r$\n$\r$\nEntering any other number or value will quit the uninstaller with a message box without removing or deleting anything." 4597 4598 LangString Msg_Unknown_Type_Param ${LANG_ENGLISH} "The entered value '$9' for the type parameter is not valid!$\r$\nUse $INSTDIR\Uninstall @CPACK_PACKAGE_VERSION@.exe /?$\r$\nto see a list of valid values." 4599 4600 ;added on 2010-10-16 4601 LangString SecGrpShortcuts_Text ${LANG_ENGLISH} "Create Shortcuts" 4602 4603 LangString SecShortcutStartmenu_Text ${LANG_ENGLISH} "Add Shortcuts to the Start Menu" 4604 4605 LangString SecShortcutDesktop_Text ${LANG_ENGLISH} "Create Shortcut on the Desktop" 4606 4607 LangString Installation_Delete_Config ${LANG_ENGLISH} "Delete (existing) Config Subdirectories/ Files" 4608 4609 ;added on 2010-10-17 4610 LangString Banner_Scan_Drive ${LANG_ENGLISH} "Scanning Drive $9" 4611 4612 LangString Banner_Installation_Found_Singular ${LANG_ENGLISH} "Found $counter_tmp installation" 4613 4614 LangString Banner_Installation_Found_Plural ${LANG_ENGLISH} "Found $counter_tmp installations" 4615 4616 ;added on 2010-10-21 4617 LangString Uninstall_Folder_Name ${LANG_ENGLISH} "Uninstall" 4618 4619 ;added on 2011-06-13 4620 LangString ^NameDA ${LANG_ENGLISH} "@CPACK_PACKAGE_NAME@ Version @CPACK_PACKAGE_VERSION@" 4621 LangString Installer ${LANG_ENGLISH} "Installer" 4622 4623;#EOF 4624