NSIS.template.in.in 141 KB

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