ui_laser_setup.nsh 107 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  1. 
  2. !include "StrFunc.nsh"
  3. !include "WordFunc.nsh"
  4. ${StrRep}
  5. ${StrStr}
  6. !include "LogicLib.nsh"
  7. !include "nsDialogs.nsh"
  8. !include "common.nsh"
  9. !include "x64.nsh"
  10. !include "MUI2.nsh"
  11. !include "WinVer.nsh"
  12. !include "commonfunc.nsh"
  13. VIProductVersion "${PRODUCT_VERSION}"
  14. VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
  15. VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
  16. VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
  17. VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
  18. VIAddVersionKey "InternalName" "${EXE_NAME}"
  19. VIAddVersionKey "FileDescription" "${PRODUCT_NAME}"
  20. VIAddVersionKey "LegalCopyright" "${PRODUCT_LEGAL}"
  21. !define INSTALL_PAGE_REG 0
  22. !define INSTALL_PAGE_CONFIG 1
  23. ;!define INSTALL_PAGE_LICENSE 1
  24. !define INSTALL_PAGE_PROCESSING 2
  25. !define INSTALL_PAGE_FINISH 3
  26. !define INSTALL_PAGE_UNISTCONFIG 4
  27. !define INSTALL_PAGE_UNISTPROCESSING 5
  28. !define INSTALL_PAGE_UNISTFINISH 6
  29. Page custom DUIPage
  30. UninstPage custom un.DUIPage
  31. Var hInstallDlg
  32. Var hInstallSubDlg
  33. Var sSetupPath
  34. Var sReserveData
  35. Var InstallState
  36. Var UnInstallValue
  37. Var basedir
  38. Var datadir
  39. Var logError
  40. Var buildModelPath
  41. Var profilePath
  42. Var buildCallPath
  43. Var dbpath
  44. Var logpath
  45. Var binPath
  46. Var javaPath
  47. Var temp12
  48. Var OLD_VER
  49. Var vc_flag
  50. Var machine
  51. Var regCode
  52. Var update
  53. !include "ui_laser_lang.nsi"
  54. Function SelectLanguage
  55. ;根据windowsapi返回值选择语言,不支持语言默认显示英文
  56. System::Call 'Kernel32::GetUserDefaultUILanguage() i.r0'
  57. ${If} $0 == '2052'
  58. StrCpy $LANGUAGE $0
  59. ${Else}
  60. StrCpy $LANGUAGE 1033
  61. ${EndIf}
  62. FunctionEnd
  63. ;在安装程序运行前的回调函数前实现
  64. Function .onInit
  65. Debug::Watcher
  66. Call SelectLanguage
  67. Call checkInstall
  68. Push ""
  69. Push ${LANG_ENGLISH} ;添加英文代码 语言代码是系统变量,多语言引入后,自动加载,拼接方式是“LANG_语言”,可以查看NSIS手册,LANG_ENGLISH的编号为1033,LANG_SIMPCHINESE为2052;
  70. Push "English"
  71. Push ${LANG_SIMPCHINESE} ;添加简体中文选项
  72. Push "简体中文"
  73. Push ${LANG_JAPANESE}
  74. Push "日本語"
  75. Push ${LANG_KOREAN}
  76. Push "한국어"
  77. Push A ; A means auto count languages for the auto count to work the first empty push (Push "") must remain
  78. ${If} $0 == '2052'
  79. LangDLL::LangDialog "安装程序语言" "请选择安装程序的语言" ;显示语言选择对话框
  80. ${ElseIf} $0 == '1033'
  81. LangDLL::LangDialog "Installer Language" "Please select the language of the installer" ;显示语言选择对话框
  82. ${ElseIf} $0 == '1041'
  83. LangDLL::LangDialog "インストーラ言語" "インストーラの言語を選択してください" ;显示语言选择对话框
  84. ${ElseIf} $0 == '1042'
  85. LangDLL::LangDialog "설치 프로그램 언어" "설치 프로그램의 언어를 선택하십시오" ;显示语言选择对话框
  86. ${Else}
  87. LangDLL::LangDialog "Installer Language" "Please select the language of the installer" ;显示语言选择对话框
  88. ${EndIf}
  89. Pop $LANGUAGE ;获得用户对于语言的选择结果 ‘$LANGUAGE’是多语言变量,在安装程序结束后,语言代码会存储在这个变量中,手动修改‘$LANGUAGE’的值后,安装包会重新选择最匹配的语言,参考最上面NSIS手册中选择界面语言步骤
  90. StrCmp $LANGUAGE "cancel" 0 +2
  91. Abort
  92. ${If} $LANGUAGE == '1033'
  93. Call startCheckEn
  94. ${ElseIf} $LANGUAGE == '1041'
  95. Call startCheckJp
  96. ${ElseIf} $LANGUAGE == '1042'
  97. Call startCheckKr
  98. ${ElseIf} $LANGUAGE == '2052'
  99. Call startCheck
  100. ${Else}
  101. Call startCheckEn
  102. ${EndIf}
  103. FunctionEnd
  104. Function checkInstall
  105. System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
  106. Pop $R0
  107. StrCmp $R0 0 SKIP RUN
  108. RUN:
  109. ${If} $LANGUAGE == '1033'
  110. MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
  111. Abort
  112. ${ElseIf} $LANGUAGE == '1041'
  113. MessageBox MB_OK|MB_USERICON "インストールが既に起動されています。重複起動を避けてください。"
  114. Abort
  115. ${ElseIf} $LANGUAGE == '1042'
  116. MessageBox MB_OK|MB_USERICON "설치 마법사가 이미 실행 중입니다. 반복적으로 켜지 마십시오."
  117. Abort
  118. ${ElseIf} $LANGUAGE == '2052'
  119. MessageBox MB_OK|MB_USERICON "有一个安装向导已经运行,请勿重复打开。"
  120. Abort
  121. ${Else}
  122. MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
  123. Abort
  124. ${EndIf}
  125. Goto END
  126. SKIP:
  127. Goto END
  128. END:
  129. FunctionEnd
  130. Function startCheck
  131. StrCpy $update "1"
  132. ${IfNot} ${AtLeastWin10}
  133. MessageBox MB_OK|MB_USERICON "本程序只能安装在windows-10(64位)系统及以上"
  134. Abort
  135. ${EndIf}
  136. SetRegView 64
  137. ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
  138. ${IF} $OLD_VER != ""
  139. ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
  140. ${If} $R0 == "0"
  141. MessageBox MB_OK|MB_USERICON '版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  142. Quit
  143. ${EndIf}
  144. ${If} $R0 == "1"
  145. MessageBox MB_OK|MB_USERICON '版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  146. Quit
  147. ${EndIf}
  148. ${If} $R0 == "2"
  149. MessageBox MB_OK|MB_USERICON '您安装的版本是 ${PRODUCT_VERSION} ,高于版本 $OLD_VER,可以执行更新操作 '
  150. StrCpy $update "0"
  151. ${EndIf}
  152. ${EndIf}
  153. FunctionEnd
  154. Function startCheckEn
  155. StrCpy $update "1"
  156. ${IfNot} ${AtLeastWin10}
  157. MessageBox MB_OK|MB_USERICON "This program can only be installed on Windows 10 (64-bit) and updated systems."
  158. Abort
  159. ${EndIf}
  160. SetRegView 64
  161. ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
  162. ${IF} $OLD_VER != ""
  163. ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
  164. ${If} $R0 == "0"
  165. MessageBox MB_OK|MB_USERICON 'Version $OLD_VER is installed on the computer. To reinstall,please uninstall the existing version first.'
  166. Quit
  167. ${EndIf}
  168. ${If} $R0 == "1"
  169. MessageBox MB_OK|MB_USERICON 'Version $OLD_VER is installed on the computer. To reinstall,please uninstall the existing version first.'
  170. Quit
  171. ${EndIf}
  172. ${If} $R0 == "2"
  173. MessageBox MB_OK|MB_USERICON 'The version you are installing is ${PRODUCT_VERSION}, which is newer than version $OLD_VER, and it can perform the updated operation'
  174. StrCpy $update "0"
  175. ${EndIf}
  176. ${EndIf}
  177. FunctionEnd
  178. Function startCheckKr
  179. StrCpy $update "1"
  180. ${IfNot} ${AtLeastWin10}
  181. MessageBox MB_OK|MB_USERICON "このプログラムは、 Windows-10(64ビット)システム以上にのみインストールできます。"
  182. Abort
  183. ${EndIf}
  184. SetRegView 64
  185. ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
  186. ${IF} $OLD_VER != ""
  187. ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
  188. ${If} $R0 == "0"
  189. MessageBox MB_OK|MB_USERICON '$OLD_VER 버전이 컴퓨터에 설치되어 있습니다.다시 설치하려면 먼저 기존 버전을 제거하십시오.'
  190. Quit
  191. ${EndIf}
  192. ${If} $R0 == "1"
  193. MessageBox MB_OK|MB_USERICON '$OLD_VER 버전이 컴퓨터에 설치되어 있습니다.다시 설치하려면 먼저 기존 버전을 제거하십시오.'
  194. Quit
  195. ${EndIf}
  196. ${If} $R0 == "2"
  197. MessageBox MB_OK|MB_USERICON '설치하는 버전은 $OLD_VER 버전보다 최신 버전인 ${PRODUCT_VERSION} 이며 업데이트된 작업을 수행할 수 있습니다. '
  198. StrCpy $update "0"
  199. ${EndIf}
  200. ${EndIf}
  201. FunctionEnd
  202. Function startCheckJp
  203. StrCpy $update "1"
  204. ${IfNot} ${AtLeastWin10}
  205. MessageBox MB_OK|MB_USERICON "이 프로그램은 Windows 10 (64 비트) 및 업데이트된 시스템에만 설치할 수 있습니다."
  206. Abort
  207. ${EndIf}
  208. SetRegView 64
  209. ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
  210. ${IF} $OLD_VER != ""
  211. ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
  212. ${If} $R0 == "0"
  213. MessageBox MB_OK|MB_USERICON 'バージョン $OLD_VER が既にインストールされていました。再インストールするには、既存のインストールをアンインストールしてください。'
  214. Quit
  215. ${EndIf}
  216. ${If} $R0 == "1"
  217. MessageBox MB_OK|MB_USERICON 'バージョン $OLD_VER が既にインストールされていました。再インストールするには、既存のインストールをアンインストールしてください。'
  218. Quit
  219. ${EndIf}
  220. ${If} $R0 == "2"
  221. MessageBox MB_OK|MB_USERICON '現在インストールのバージョン:${PRODUCT_VERSION}、バージョン $OLD_VER より新しいです。アップデートが可能です。 '
  222. StrCpy $update "0"
  223. ${EndIf}
  224. ${EndIf}
  225. FunctionEnd
  226. Function un.checkInstall
  227. SetRegView 64
  228. ReadRegStr $LANGUAGE HKLM "Software\${PRODUCT_PATHNAME}" "language"
  229. System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
  230. Pop $R0
  231. StrCmp $R0 0 SKIP RUN
  232. RUN:
  233. ${If} $LANGUAGE == '1033'
  234. MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
  235. Abort
  236. ${ElseIf} $LANGUAGE == '1041'
  237. MessageBox MB_OK|MB_USERICON "インストールが既に起動されています。重複起動を避けてください。"
  238. Abort
  239. ${ElseIf} $LANGUAGE == '1042'
  240. MessageBox MB_OK|MB_USERICON "설치 마법사가 이미 실행 중입니다. 반복적으로 켜지 마십시오."
  241. Abort
  242. ${ElseIf} $LANGUAGE == '2052'
  243. MessageBox MB_OK|MB_USERICON "有一个安装向导已经运行,请勿重复打开。"
  244. Abort
  245. ${Else}
  246. MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
  247. Abort
  248. ${EndIf}
  249. Goto END
  250. SKIP:
  251. Goto END
  252. END:
  253. FunctionEnd
  254. Function un.onInit
  255. ;Debug::Watcher
  256. SetRegView 64
  257. Call un.checkInstall
  258. FunctionEnd
  259. Function DUIPage
  260. StrCpy $InstallState "0"
  261. InitPluginsDir
  262. SetOutPath "$PLUGINSDIR"
  263. File "${INSTALL_LICENCE_FILENAME_ZH}"
  264. File "${INSTALL_LICENCE_FILENAME_EN}"
  265. File "${INSTALL_RES_PATH}"
  266. File /oname=logo.ico "${INSTALL_ICO}"
  267. ; File /oname=4dage.exe "${INSTALL_REG}"
  268. StrCmp $LANGUAGE 2052 ZH_INI EN_INI
  269. EN_INI:
  270. nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" "${INSTALL_LICENCE_FILENAME_EN}"
  271. Goto END
  272. ZH_INI:
  273. nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" "${INSTALL_LICENCE_FILENAME_ZH}"
  274. Goto END
  275. END:
  276. Pop $hInstallDlg
  277. ; MessageBox MB_OK "Exit code:$machine"
  278. Call initConfigPage
  279. Call BindUIControls
  280. nsExec::ExecToStack 'cmd.exe /c powercfg.exe /hibernate on '
  281. ${If} $update == "1"
  282. ;新装
  283. ;生成安装路径,包含识别旧的安装路径
  284. Call GenerateSetupAddress
  285. #设置控件显示安装路径
  286. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
  287. Call OnRichEditTextChange
  288. #nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnAgreement" "text" " 用户许可协议"
  289. ${Else}
  290. ;更新
  291. SetRegView 64
  292. ReadRegStr $0 HKLM "Software\${PRODUCT_PATHNAME}" "InstPath"
  293. ${If} "$0" != "" #路径不存在,则重新选择路径
  294. #路径读取到了,直接使用
  295. #再判断一下这个路径是否有效
  296. nsNiuniuSkin::StringHelper "$0" "\\" "\" "replace"
  297. Pop $0
  298. StrCpy $INSTDIR "$0"
  299. ${EndIf}
  300. #设置控件显示安装路径
  301. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
  302. Call OnRichEditTextChange
  303. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "enabled" "false"
  304. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnSelectDir" "visible" "false"
  305. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "text" $(ONE_CLICK_UPDATE)
  306. ${EndIf}
  307. ;设置安装包的标题及任务栏显示
  308. nsNiuniuSkin::SetWindowTile $hInstallDlg "$(PRODUCT_NAME_LANG)$(SETUP)"
  309. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
  310. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licensename" "text" $(USER_LICENSE_AGREEMENT)
  311. nsNiuniuSkin::ShowPage 0
  312. FunctionEnd
  313. Function un.DUIPage
  314. StrCpy $InstallState "0"
  315. InitPluginsDir
  316. SetOutPath "$PLUGINSDIR"
  317. File "${INSTALL_RES_PATH}"
  318. File /oname=logo.ico "${UNINSTALL_ICO}"
  319. nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" ""
  320. Pop $hInstallDlg
  321. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTCONFIG}
  322. Call un.initUnInstallPage
  323. nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}$(UNINSTALL_SETUP)"
  324. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390s
  325. Call un.BindUnInstUIControls
  326. nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAutoRun" "selected" "true"
  327. nsNiuniuSkin::ShowPage 0
  328. FunctionEnd
  329. Function un.BindUnInstUIControls
  330. GetFunctionAddress $0 un.ExitDUISetup
  331. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUninstalled" $0
  332. GetFunctionAddress $0 un.onUninstall
  333. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUnInstall" $0
  334. GetFunctionAddress $0 un.ExitDUISetup
  335. nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
  336. GetFunctionAddress $0 un.ExitDUISetup
  337. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUnClose" $0
  338. GetFunctionAddress $0 un.OnBtnMin
  339. nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
  340. GetFunctionAddress $0 un.BtnDirPre
  341. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
  342. ; GetFunctionAddress $0 un.onNoPassUninstall
  343. ; nsNiuniuSkin::BindCallBack $hInstallDlg "backupBtnOK" $0
  344. ; GetFunctionAddress $0 un.onPassUninstall
  345. ; nsNiuniuSkin::BindCallBack $hInstallDlg "gotouninstall" $0
  346. GetFunctionAddress $0 un.OnbtnUninstalledReboot
  347. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUninstalledReboot" $0
  348. FunctionEnd
  349. Function BindUIControls
  350. GetFunctionAddress $0 OnExitDUISetup
  351. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseClose" $0
  352. GetFunctionAddress $0 OnBtnMin
  353. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseMin" $0
  354. GetFunctionAddress $0 OnBtnLicenseClick
  355. nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgreement" $0
  356. GetFunctionAddress $0 OnExitDUISetup
  357. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirClose" $0
  358. GetFunctionAddress $0 OnExitDUISetup
  359. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseCancel" $0
  360. GetFunctionAddress $0 OnBtnMin
  361. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirMin" $0
  362. GetFunctionAddress $0 OnBtnSelectDir
  363. nsNiuniuSkin::BindCallBack $hInstallDlg "btnSelectDir" $0
  364. GetFunctionAddress $0 OnBtnDirPre
  365. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
  366. GetFunctionAddress $0 OnBtnShowConfig
  367. nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgree" $0
  368. GetFunctionAddress $0 OnBtnCancel
  369. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirCancel" $0
  370. GetFunctionAddress $0 OnBtnInstall
  371. nsNiuniuSkin::BindCallBack $hInstallDlg "btnInstall" $0
  372. GetFunctionAddress $0 OnExitDUISetup
  373. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailClose" $0
  374. GetFunctionAddress $0 OnBtnMin
  375. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailMin" $0
  376. GetFunctionAddress $0 OnFinished
  377. nsNiuniuSkin::BindCallBack $hInstallDlg "btnRun" $0
  378. GetFunctionAddress $0 OnBtnMin
  379. nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
  380. GetFunctionAddress $0 OnExitDUISetup
  381. nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
  382. GetFunctionAddress $0 OnCheckLicenseClick
  383. nsNiuniuSkin::BindCallBack $hInstallDlg "chkAgree" $0
  384. GetFunctionAddress $0 OnBtnShowMore
  385. nsNiuniuSkin::BindCallBack $hInstallDlg "btnShowMore" $0
  386. GetFunctionAddress $0 OnBtnHideMore
  387. nsNiuniuSkin::BindCallBack $hInstallDlg "btnHideMore" $0
  388. GetFunctionAddress $0 OnSysCommandCloseEvent
  389. nsNiuniuSkin::BindCallBack $hInstallDlg "syscommandclose" $0
  390. GetFunctionAddress $0 OnRichEditTextChange
  391. nsNiuniuSkin::BindCallBack $hInstallDlg "editDir" $0
  392. FunctionEnd
  393. Function un.OnbtnUninstalledReboot
  394. ; MessageBox MB_OK "OnbtnUninstalledR:eboot--Reboot"
  395. Reboot
  396. FunctionEnd
  397. Function OnRichEditTextChange
  398. nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
  399. Pop $0
  400. StrCpy $INSTDIR "$0"
  401. Call onVerifyInstDir
  402. Pop $0
  403. ${If} $0 == 1
  404. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_ZH_PATH)
  405. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  406. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  407. goto TextChangeAbort
  408. ${EndIf}
  409. ${If} $0 == 2
  410. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_CANNOT_EMPTY)
  411. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  412. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  413. goto TextChangeAbort
  414. ${EndIf}
  415. Call onVerifySpecialInstDir
  416. ${If} $0 == 1
  417. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_SPECIAL_CHARACTERS)
  418. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  419. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  420. goto TextChangeAbort
  421. ${EndIf}
  422. Call IsSetupPathIlleagal
  423. ${If} $R5 == "0"
  424. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_ERROR)
  425. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  426. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  427. goto TextChangeAbort
  428. ${EndIf}
  429. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#FF999999"
  430. ${If} $R0 > 1024
  431. IntOp $R1 $R0 % 1024
  432. IntOp $R0 $R0 / 1024;
  433. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "$(REMAINING_SPACE):$R0.$R1GB"
  434. ${Else}
  435. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "$(REMAINING_SPACE):$R0.$R1MB"
  436. ${endif}
  437. ${IF} ${CJ} == "true"
  438. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  439. ${Else}
  440. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  441. Pop $0
  442. ${If} $0 == "1"
  443. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  444. ${Else}
  445. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  446. ${EndIf}
  447. ${EndIf}
  448. TextChangeAbort:
  449. FunctionEnd
  450. Function OnCheckLicenseClick
  451. ${IF} ${CJ} == "true"
  452. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  453. ${Else}
  454. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  455. Pop $0
  456. ${If} $0 == "0"
  457. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  458. ${Else}
  459. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  460. ${EndIf}
  461. ${EndIf}
  462. FunctionEnd
  463. Function OnBtnLicenseClick
  464. ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_LICENSE}
  465. Call initLicensePage
  466. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "true"
  467. nsNiuniuSkin::GetControlAttribute $hInstallDlg "moreconfiginfo" "visible"
  468. Pop $0
  469. ${If} $0 = 0
  470. ;pos="10,35,560,405"
  471. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,385"
  472. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "270"
  473. ${Else}
  474. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,495"
  475. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "375"
  476. ${EndIf}
  477. FunctionEnd
  478. Section "silentInstallSec" SEC01
  479. #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent install code here."
  480. SectionEnd
  481. Function ShowMsgBox
  482. nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
  483. Pop $hInstallSubDlg
  484. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "btnOK" "text" $(BTN_CONFIRM)
  485. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "btnCancel" "text" $(BTN_CANCEL)
  486. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" $(PROMPT)
  487. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
  488. ${If} "$R7" == "1"
  489. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
  490. ${EndIf}
  491. nsNiuniuSkin::ShowSkinSubPage 0
  492. FunctionEnd
  493. Function OnBtnInstall
  494. nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
  495. Pop $0
  496. StrCpy $INSTDIR "$0"
  497. Call onVerifyInstDir
  498. Pop $0
  499. ${If} $0 == 1
  500. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_ZH_PATH)
  501. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  502. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  503. goto InstallAbort
  504. ${EndIf}
  505. ${If} $0 == 2
  506. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_CANNOT_EMPTY)
  507. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  508. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  509. goto InstallAbort
  510. ${EndIf}
  511. Call onVerifySpecialInstDir
  512. ${If} $0 == 1
  513. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_SPECIAL_CHARACTERS)
  514. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  515. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  516. goto InstallAbort
  517. ${EndIf}
  518. Call IsSetupPathIlleagal
  519. ${If} $R5 == "0"
  520. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_ERROR)
  521. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  522. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  523. goto InstallAbort
  524. ${EndIf}
  525. ; MessageBox MB_OK|MB_USERICON '$INSTDIR\install.flag'
  526. ${If} ${FileExists} "$INSTDIR\install.flag"
  527. SetRebootFlag true
  528. MessageBox MB_OK $(REBOOT_PROMPT)
  529. Quit
  530. ${EndIf}
  531. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#FF999999"
  532. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  533. Pop $0
  534. StrCpy $0 "1"
  535. StrCmp $0 "0" InstallAbort 0
  536. nsProcess::_FindProcess "${EXE_NAME_EXT}"
  537. Pop $R0
  538. ${If} $R0 == 0
  539. StrCpy $R8 "${PRODUCT_NAME} $(TO_RUNNING)"
  540. StrCpy $R7 "0"
  541. Call ShowMsgBox
  542. goto InstallAbort
  543. ${EndIf}
  544. nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
  545. Pop $0
  546. StrCmp $0 "" InstallAbort 0
  547. Call AdjustInstallPath
  548. StrCpy $sSetupPath "$INSTDIR"
  549. Call IsSetupPathIlleagal
  550. ${If} $R5 == "0"
  551. StrCpy $R8 $(PATH_ERROR_TWO)
  552. StrCpy $R7 "0"
  553. Call ShowMsgBox
  554. goto InstallAbort
  555. ${EndIf}
  556. ${If} $R5 == "-1"
  557. StrCpy $R8 $(DISK_SPACE_ERROR)
  558. StrCpy $R7 "0"
  559. Call ShowMsgBox
  560. goto InstallAbort
  561. ${EndIf}
  562. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
  563. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
  564. Call initInstallingPage
  565. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_PROCESSING}
  566. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "min" "0"
  567. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "max" "100"
  568. #Call BakFiles
  569. ${If} $update == "1"
  570. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INSTALLING)
  571. ${Else}
  572. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(STOPPING_SERVICE)
  573. SimpleSC::StopService "lasermongodb" 0 30
  574. SimpleSC::StopService "lasermysql" 0 30
  575. SimpleSC::StopService "laserredis" 0 30
  576. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(REMOVE_FILES)
  577. RMDir /r "$INSTDIR\bin"
  578. BgWorker::CallAndWait
  579. RMDir /r "$INSTDIR\CGAII"
  580. Sleep 2000
  581. BgWorker::CallAndWait
  582. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(UPDATING)
  583. ${EndIf}
  584. GetFunctionAddress $0 ExtractFunc
  585. BgWorker::CallAndWait
  586. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkShotcut" "selected"
  587. #Pop $R0
  588. # ${If} $R0 == "1"
  589. # SetShellVarContext all
  590. # CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
  591. # SetShellVarContext current
  592. # ${EndIf}
  593. SetOutPath "$INSTDIR\bin"
  594. SetShellVarContext all
  595. Delete "$DESKTOP\四维看看本地版.lnk"
  596. Delete "$DESKTOP\4DKanKan.lnk"
  597. CreateShortCut "$DESKTOP\$(PRODUCT_NAME_LANG).lnk" "$INSTDIR\${EXE_NAME}"
  598. SetShellVarContext current
  599. Call CreateAppShortcut
  600. Call CreateUninstall
  601. ${If} $update == "1"
  602. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INITIALIZING)
  603. GetFunctionAddress $0 OnEnvInstall
  604. BgWorker::CallAndWait
  605. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INITIALIZING_SERVICE)
  606. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" ""
  607. GetFunctionAddress $0 installService
  608. BgWorker::CallAndWait
  609. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INITIALIZING_SERVICE_DONE)
  610. ${Else}
  611. SimpleSC::StartService "lasermongodb" "" 30
  612. SimpleSC::StartService "lasermysql" "" 30
  613. SimpleSC::StartService "laserredis" "" 30
  614. Sleep 2000
  615. ;
  616. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_DATA\' '\' '\\'
  617. StrCpy $buildModelPath $0
  618. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_STATIC\' '\' '\\'
  619. StrCpy $profilePath $0
  620. ${StrRep} $0 '$INSTDIR\CGAII' '\' '\\'
  621. StrCpy $buildCallPath $0
  622. ${StrRep} $0 '$INSTDIR\bin\resources\static' '\' '\\'
  623. StrCpy $binPath $0
  624. ${StrRep} $0 '$INSTDIR\jdk1.8\bin\java.exe' '\' '\\'
  625. StrCpy $javaPath $0
  626. nsJSON::Set /file $INSTDIR\bin\resources\static\setting.json
  627. nsJSON::Set /value `{}`
  628. nsJSON::Set `sceneConfig` /value `"config.json"`
  629. nsJSON::Set `sceheKey` /value `"id"`
  630. nsJSON::Set `sceneBundle` /value `"./build.zip"`
  631. nsJSON::Set `sceneBundleDir` /value `"capture"`
  632. nsJSON::Set `buildModelPath` /value `"$buildModelPath"`
  633. nsJSON::Set `javaPort` /value `9000`
  634. nsJSON::Set `v4JavaPort` /value `9101`
  635. nsJSON::Set `javaPath` /value `"$javaPath"`
  636. nsJSON::Set `profilePath` /value `"$profilePath"`
  637. nsJSON::Set `buildCallPath` /value `"$buildCallPath"`
  638. nsJSON::Set `binPath` /value `"$binPath"`
  639. nsJSON::Set `fuse` /value `${FUSE}`
  640. nsJSON::Set `ver` /value `${VER}`
  641. nsJSON::Set `version` /value `"${VERSION}"`
  642. nsJSON::Serialize /format /file $INSTDIR\bin\resources\static\setting.json
  643. nsExec::ExecToStack '"$INSTDIR\tools\update.bat" $INSTDIR '
  644. ;nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m u -i $INSTDIR"
  645. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(UPDATING_DONE)
  646. ${EndIf}
  647. StrCpy $InstallState "1"
  648. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_FINISH}
  649. Call initFinishPage
  650. #Call OnFinished
  651. ${If} $update == "0"
  652. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnRun" "text" $(UPDATING_DONE)
  653. ${EndIf}
  654. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
  655. ;完成安装删除计划任务
  656. nsExec::ExecToStack 'schtasks /delete /tn "DeleteInstallFlagTask" /f'
  657. InstallAbort:
  658. FunctionEnd
  659. Function ExtractCallback
  660. Pop $1
  661. Pop $2
  662. System::Int64Op $1 * 100
  663. Pop $3
  664. System::Int64Op $3 / $2
  665. Pop $0
  666. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "$0"
  667. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "$0%"
  668. ${If} $1 == $2
  669. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "100"
  670. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "100%"
  671. ${EndIf}
  672. FunctionEnd
  673. Function OnSysCommandCloseEvent
  674. Call OnExitDUISetup
  675. FunctionEnd
  676. Function OnExitDUISetup
  677. ${If} $InstallState == "0"
  678. StrCpy $R8 "$(CONFIRM_EXIT)"
  679. StrCpy $R7 "1"
  680. Call ShowMsgBox
  681. pop $0
  682. ${If} $0 == 0
  683. goto endfun
  684. ${EndIf}
  685. ${EndIf}
  686. nsNiuniuSkin::ExitDUISetup
  687. endfun:
  688. FunctionEnd
  689. Function OnBtnMin
  690. SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
  691. FunctionEnd
  692. Function OnBtnCancel
  693. nsNiuniuSkin::ExitDUISetup
  694. FunctionEnd
  695. Function OnEnvInstall
  696. EnVar::SetHKLM
  697. EnVar::AddValue FDMGEA_HOME "$INSTDIR"
  698. ;EnVar::SetHKLM
  699. ;EnVar::AddValue JAVA_HOME "$INSTDIR\jdk1.8"
  700. EnVar::SetHKLM
  701. EnVar::AddValue MYSQL_HOME "$INSTDIR\mysql"
  702. EnVar::SetHKLM
  703. EnVar::AddValue REDIS_HOME "$INSTDIR\redis"
  704. EnVar::SetHKLM
  705. EnVar::AddValue 4DKK_HOME "$INSTDIR\CGAII;$INSTDIR\CGAII\3dtile"
  706. EnVar::SetHKLM
  707. EnVar::AddValue MONGODB_HOME "$INSTDIR\mongodb"
  708. ;EnVar::SetHKLM
  709. ;EnVar::AddValue CLASS_PATH ".;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
  710. EnVar::SetHKLM
  711. ;EnVar::AddValue "Path" "$INSTDIR\jdk1.8\bin;$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;"
  712. EnVar::AddValue "Path" "$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;$INSTDIR\CGAII\3dtile"
  713. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  714. ;nsExec::ExecToStack '"$INSTDIR\tools\env_install.bat" $INSTDIR '
  715. FunctionEnd
  716. Function un.OnEnvDownInstall
  717. EnVar::SetHKLM
  718. EnVar::Delete "FDMGEA_HOME" "$INSTDIR"
  719. ;EnVar::Delete "JAVA_HOME" "$INSTDIR\jdk1.8"
  720. EnVar::Delete "MYSQL_HOME" "$INSTDIR\mysql"
  721. EnVar::Delete "REDIS_HOME" "$INSTDIR\redis"
  722. EnVar::Delete "4DKK_HOME" "$INSTDIR\CGAII"
  723. EnVar::Delete "4DKK_HOME" "$INSTDIR\CGAII\3dtile"
  724. EnVar::Delete "MONGODB_HOME" "$INSTDIR\mongodb"
  725. ;EnVar::Delete "CLASS_PATH" "%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
  726. ;EnVar::DeleteValue "PATH" "%JAVA_HOME%\bin"
  727. EnVar::DeleteValue "PATH" "$INSTDIR\mysql\bin"
  728. EnVar::DeleteValue "PATH" "$INSTDIR\mongodb\bin"
  729. EnVar::DeleteValue "PATH" "$INSTDIR\redis"
  730. EnVar::DeleteValue "PATH" "$INSTDIR\CGAII"
  731. EnVar::DeleteValue "PATH" "$INSTDIR\CGAII\lib"
  732. EnVar::DeleteValue "PATH" "$INSTDIR\CGAII\3dtile"
  733. ;nsExec::ExecToStack '"$INSTDIR\tools\uninstall.bat" $INSTDIR '
  734. FunctionEnd
  735. Function un.installService
  736. nsExec::ExecToStack '"$INSTDIR\tools\unservice.bat" $INSTDIR '
  737. SimpleSC::ExistsService "lasermongodb"
  738. Pop $0
  739. ${If} $0 == 0
  740. SimpleSC::StopService "lasermongodb" 0 30
  741. SimpleSC::RemoveService "lasermongodb"
  742. ${EndIf}
  743. SimpleSC::ExistsService "lasermysql"
  744. Pop $0
  745. ${If} $0 == 0
  746. SimpleSC::StopService "lasermysql" 0 30
  747. SimpleSC::RemoveService "lasermysql"
  748. ${EndIf}
  749. SimpleSC::ExistsService "laserredis"
  750. Pop $0
  751. ${If} $0 == 0
  752. SimpleSC::StopService "laserredis" 0 30
  753. SimpleSC::RemoveService "laserredis"
  754. ${EndIf}
  755. SimpleSC::ExistsService "checkLaserProcess"
  756. Pop $0
  757. ${If} $0 == 0
  758. SimpleSC::StopService "checkLaserProcess" 0 30
  759. SimpleSC::RemoveService "checkLaserProcess"
  760. ${EndIf}
  761. FunctionEnd
  762. Function installService
  763. ${StrRep} $0 '$INSTDIR\mysql' '\' '\\'
  764. StrCpy $basedir $0
  765. ${StrRep} $0 '$INSTDIR\mysql\data' '\' '\\'
  766. StrCpy $datadir $0
  767. ${StrRep} $0 '$INSTDIR\mysql\logs.log' '\' '\\'
  768. StrCpy $logError $0
  769. WriteINIStr $INSTDIR\mysql\my.ini mysqld port 3307
  770. WriteINIStr $INSTDIR\mysql\my.ini mysqld basedir $basedir
  771. WriteINIStr $INSTDIR\mysql\my.ini mysqld datadir $datadir
  772. WriteINIStr $INSTDIR\mysql\my.ini mysqld log-error $logError
  773. WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connections 1000
  774. WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connect_errors 10
  775. WriteINIStr $INSTDIR\mysql\my.ini mysqld character-set-server utf8mb4
  776. WriteINIStr $INSTDIR\mysql\my.ini mysqld default-storage-engine INNODB
  777. WriteINIStr $INSTDIR\mysql\my.ini mysqld default_authentication_plugin mysql_native_password
  778. WriteINIStr $INSTDIR\mysql\my.ini mysqld local_infile ON
  779. WriteINIStr $INSTDIR\mysql\my.ini mysql default-character-set utf8mb4
  780. WriteINIStr $INSTDIR\mysql\my.ini mysql local_infile ON
  781. WriteINIStr $INSTDIR\mysql\my.ini client port 3307
  782. WriteINIStr $INSTDIR\mysql\my.ini client default-character-set utf8mb4
  783. Sleep 2000
  784. SetOutPath "$INSTDIR\mysql\bin"
  785. ReadRegStr $vc_flag HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" "Installed"
  786. ${IF} $vc_flag != "1"
  787. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\VC_redist.x64.exe /install /quiet /norestart'
  788. ${EndIf}
  789. Sleep 2000
  790. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --initialize-insecure --lower-case-table-names=1'
  791. Sleep 2000
  792. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
  793. ; Pop $0
  794. ; Pop $1
  795. ; ${If} $0 = 0
  796. ; nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
  797. ; ${Else}
  798. ; ;MessageBox mb_ok "code=$0,mes=$1"
  799. ; Sleep 2000
  800. ; nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --initialize-insecure --lower-case-table-names=1'
  801. ; Sleep 2000
  802. ; nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
  803. ; ${EndIf}
  804. IfFileExists "$INSTDIR\USER_DATA\data\*.*" 0 static_not_found
  805. CopyFiles /SILENT $INSTDIR\USER_DATA\data\*.* $INSTDIR\mysql\data
  806. RMDir /r "$INSTDIR\USER_DATA\data\"
  807. Delete "$INSTDIR\mysql\sqlfile\fdkk_laser.sql"
  808. goto static_end_of
  809. static_not_found:
  810. goto static_end_of
  811. static_end_of:
  812. nsExec::ExecToStack '"cmd.exe" /c powercfg.exe /hibernate off '
  813. SimpleSC::StartService "lasermysql" "" 30
  814. SetOutPath "$INSTDIR\redis"
  815. nsExec::ExecToStack '"cmd.exe" /c redis-server.exe --service-install "$INSTDIR\redis\redis.windows.conf" --service-name laserredis --loglevel verbose'
  816. SimpleSC::StartService "laserredis" "" 30
  817. nsExec::ExecToStack '"cmd.exe" /c sc config laserredis start=auto'
  818. SimpleSC::RestartService "laserredis" "" 30
  819. Sleep 2000
  820. SetOutPath "$INSTDIR\mongodb"
  821. ${StrRep} $0 '$INSTDIR\mongodb\db' '\' '\\'
  822. StrCpy $dbpath $0
  823. ${StrRep} $0 '$INSTDIR\mongodb\logs\mongo.log' '\' '\\'
  824. StrCpy $logpath $0
  825. ClearErrors
  826. FileOpen $0 $INSTDIR\mongodb\mongo.conf w
  827. IfErrors otherW
  828. FileWrite $0 'port=29031$\n'
  829. FileWrite $0 'dbpath=$dbpath$\n'
  830. FileWrite $0 'logpath=$logpath$\n'
  831. FileWrite $0 'logappend=true$\n'
  832. FileWrite $0 'maxConns=1000$\n'
  833. FileClose $0
  834. goto done
  835. otherW:
  836. ;nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m w -i $INSTDIR\mongodb"
  837. nsExec::ExecToStack '"$INSTDIR\tools\wirteMconf.bat" $INSTDIR\mongodb\ '
  838. goto done
  839. done:
  840. nsExec::ExecToStack '"cmd.exe" /c sc create lasermongodb binpath= "$INSTDIR\mongodb\bin\mongod.exe --config $INSTDIR\mongodb\mongo.conf --service" start= auto'
  841. SimpleSC::StartService "lasermongodb" "" 30
  842. Sleep 2000
  843. ; IfFileExists "$INSTDIR\USER_DATA\pro\*.*" 0 pro_not_found
  844. ; CopyFiles /SILENT $INSTDIR\USER_DATA\pro\*.* $INSTDIR\4DKK_PROGRAM_DATA
  845. ; RMDir /r "$INSTDIR\USER_DATA\pro"
  846. ; goto pro_end_of
  847. ; pro_not_found:
  848. ; goto pro_end_of
  849. ; pro_end_of:
  850. Sleep 2000
  851. ;
  852. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_DATA\' '\' '\\'
  853. StrCpy $buildModelPath $0
  854. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_STATIC\' '\' '\\'
  855. StrCpy $profilePath $0
  856. ${StrRep} $0 '$INSTDIR\CGAII' '\' '\\'
  857. StrCpy $buildCallPath $0
  858. ${StrRep} $0 '$INSTDIR\bin\resources\static' '\' '\\'
  859. StrCpy $binPath $0
  860. ${StrRep} $0 '$INSTDIR\jdk1.8\bin\java.exe' '\' '\\'
  861. StrCpy $javaPath $0
  862. nsJSON::Set /file $INSTDIR\bin\resources\static\setting.json
  863. nsJSON::Set /value `{}`
  864. nsJSON::Set `sceneConfig` /value `"config.json"`
  865. nsJSON::Set `sceheKey` /value `"id"`
  866. nsJSON::Set `sceneBundle` /value `"./build.zip"`
  867. nsJSON::Set `sceneBundleDir` /value `"capture"`
  868. nsJSON::Set `buildModelPath` /value `"$buildModelPath"`
  869. nsJSON::Set `javaPort` /value `9000`
  870. nsJSON::Set `v4JavaPort` /value `9101`
  871. nsJSON::Set `javaPath` /value `"$javaPath"`
  872. nsJSON::Set `profilePath` /value `"$profilePath"`
  873. nsJSON::Set `buildCallPath` /value `"$buildCallPath"`
  874. nsJSON::Set `binPath` /value `"$binPath"`
  875. nsJSON::Set `fuse` /value `${FUSE}`
  876. nsJSON::Set `ver` /value `${VER}`
  877. nsJSON::Set `version` /value `"${VERSION}"`
  878. nsJSON::Serialize /format /file $INSTDIR\bin\resources\static\setting.json
  879. ;nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m l -i $INSTDIR"
  880. nsExec::ExecToStack '"$INSTDIR\tools\service.bat" $INSTDIR '
  881. nsExec::ExecToStack '"$INSTDIR\tools\update.bat" $INSTDIR '
  882. ; FileOpen $0 $INSTDIR\bin\resources\static\4dmega.vmoptions w
  883. ; IfErrors done
  884. ; FileWrite $0 '-DBIN_PATH=$INSTDIR\bin\resources\static$\n'
  885. ; FileWrite $0 '-DPROFILE_PATH=$INSTDIR\4DKK_PROGRAM_STATIC\$\n'
  886. ; FileWrite $0 '-DBUILD_MODEL_PATH=$INSTDIR\4DKK_PROGRAM_DATA\$\n'
  887. ; FileWrite $0 '-DBUILD_CALL_PATH=$INSTDIR\CGAII\$\n'
  888. ; FileWrite $0 '-Dspring.profiles.active=standAloneProd$\n'
  889. ; FileWrite $0 '-Dserver.port=9000$\n'
  890. ; FileClose $0
  891. ; done:
  892. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\tools\MonitorPid.exe install '
  893. functionend
  894. Function OnFinished
  895. #MessageBox MB_YESNO|MB_ICONQUESTION "$(INSTALL_REBOOT)" IDNO +2
  896. #Reboot
  897. #Exec "$INSTDIR${EXE_NAME}"
  898. nsExec::ExecToStack 'ie4uinit.exe -ClearIconCache'
  899. nsExec::ExecToStack 'ie4uinit.exe -show'
  900. System::Call 'shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)'
  901. WriteRegStr HKLM "Software\${PRODUCT_PATHNAME}" "language" $LANGUAGE
  902. Call OnExitDUISetup
  903. FunctionEnd
  904. Function OnBtnSelectDir
  905. nsNiuniuSkin::SelectInstallDirEx $hInstallDlg $(PLEASE_SELECT_INSTALLATION_PATH)
  906. Pop $0
  907. ${Unless} "$0" == ""
  908. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" $0
  909. ${EndUnless}
  910. FunctionEnd
  911. Function StepHeightSizeAsc
  912. ${ForEach} $R0 390 500 + 10
  913. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
  914. Sleep 5
  915. ${Next}
  916. FunctionEnd
  917. Function StepHeightSizeDsc
  918. ${ForEach} $R0 480 390 - 10
  919. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
  920. Sleep 5
  921. ${Next}
  922. FunctionEnd
  923. Function OnBtnShowMore
  924. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
  925. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
  926. nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "true"
  927. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "true"
  928. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "false"
  929. GetFunctionAddress $0 StepHeightSizeAsc
  930. BgWorker::CallAndWait
  931. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 510
  932. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
  933. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
  934. FunctionEnd
  935. Function OnBtnHideMore
  936. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
  937. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
  938. nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "false"
  939. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "false"
  940. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "true"
  941. GetFunctionAddress $0 StepHeightSizeDsc
  942. BgWorker::CallAndWait
  943. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
  944. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
  945. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
  946. FunctionEnd
  947. Function OnBtnShowConfig
  948. ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
  949. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "false"
  950. FunctionEnd
  951. Function OnBtnDirPre
  952. StrCpy $R8 "$(CONFIRM_EXIT)"
  953. StrCpy $R7 "0"
  954. Call ShowMsgBox
  955. ;nsNiuniuSkin::PrePage "wizardTab"
  956. FunctionEnd
  957. Function un.BtnDirPre
  958. StrCpy $R8 "$(UNINSTALL)"
  959. StrCpy $R7 "0"
  960. Call un.ShowMsgBox
  961. ;nsNiuniuSkin::PrePage "wizardTab"
  962. FunctionEnd
  963. Function un.ShowMsgBoxBackUps
  964. nsNiuniuSkin::InitSkinSubPage "msgBox_backup.xml" "backupBtnOK" "gotouninstall"
  965. Pop $hInstallSubDlg
  966. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" $(UNINSTALL_ERROR)
  967. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "backupBtnOK" "text" $(I_KNOW)
  968. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" $(PROMPT)
  969. nsNiuniuSkin::ShowSkinSubPage 0
  970. FunctionEnd
  971. Function un.ShowMsgBox
  972. nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
  973. Pop $hInstallSubDlg
  974. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" $(PROMPT)
  975. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
  976. ${If} "$R7" == "1"
  977. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
  978. ${EndIf}
  979. nsNiuniuSkin::ShowSkinSubPage 0
  980. FunctionEnd
  981. Function un.ExitDUISetup
  982. nsExec::ExecToStack 'ie4uinit.exe -ClearIconCache'
  983. nsExec::ExecToStack 'ie4uinit.exe -show'
  984. System::Call 'shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)'
  985. nsNiuniuSkin::ExitDUISetup
  986. FunctionEnd
  987. Function un.OnBtnMin
  988. SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
  989. FunctionEnd
  990. Section "un.silentInstallSec" SEC02
  991. #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent uninstall code here."
  992. SectionEnd
  993. Function un.onUninstall
  994. nsProcess::_FindProcess "${EXE_NAME_EXT}"
  995. Pop $R0
  996. ${If} $R0 == 0
  997. StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
  998. StrCpy $R7 "0"
  999. Call un.ShowMsgBox
  1000. goto InstallAbort
  1001. ${EndIf}
  1002. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkbox_userdata" "selected"
  1003. Pop $0
  1004. StrCpy $sReserveData $0
  1005. ${If} $sReserveData == 1
  1006. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" $(PREPARING_TO_UNINSTALL)
  1007. CreateDirectory $INSTDIR\USER_DATA
  1008. ; nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m v -i $INSTDIR"
  1009. ; Pop $0
  1010. SimpleSC::GetServiceStatus "lasermongodb"
  1011. Pop $0 ; 返回错误码,0 表示成功,非0 表示失败
  1012. Pop $1 ; 返回服务状态,状态值参考 Windows 服务状态代码
  1013. ${If} $0 == 0
  1014. ${If} $1 == 4 ; 服务状态值为 4 表示服务正在运行
  1015. Call un.onPassUninstall
  1016. ${Else}
  1017. RMDir /r "$INSTDIR\USER_DATA"
  1018. Call un.ShowMsgBoxBackUps
  1019. Pop $0
  1020. ${If} $0 == 0
  1021. Call un.onPassUninstall
  1022. ${EndIf}
  1023. ${If} $0 == 1
  1024. Call un.onNoPassUninstall
  1025. ${EndIf}
  1026. ${EndIf}
  1027. ${Else}
  1028. RMDir /r "$INSTDIR\USER_DATA"
  1029. Call un.ShowMsgBoxBackUps
  1030. Pop $0
  1031. ${If} $0 == 0
  1032. Call un.onPassUninstall
  1033. ${EndIf}
  1034. ${If} $0 == 1
  1035. Call un.onNoPassUninstall
  1036. ${EndIf}
  1037. ${EndIf}
  1038. ${Else}
  1039. Call un.onPassUninstall
  1040. ${EndIf}
  1041. InstallAbort:
  1042. FunctionEnd
  1043. Function un.onNoPassUninstall
  1044. nsNiuniuSkin::ExitDUISetup
  1045. FunctionEnd
  1046. Function un.onPassUninstall
  1047. ${If} $sReserveData == 1
  1048. CreateDirectory $INSTDIR\USER_DATA
  1049. ${EndIf}
  1050. Call un.initUninstallingPage
  1051. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
  1052. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTPROCESSING}
  1053. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "min" "0"
  1054. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "max" "100"
  1055. IntOp $UnInstallValue 0 + 1
  1056. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" $(PREPARING_TO_UNINSTALL)
  1057. ; nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m b -i $INSTDIR "
  1058. ; BgWorker::CallAndWait
  1059. GetFunctionAddress $0 un.OnEnvDownInstall
  1060. BgWorker::CallAndWait
  1061. nsExec::ExecToStack 'cmd.exe /c powercfg.exe /hibernate on '
  1062. GetFunctionAddress $0 un.installService
  1063. BgWorker::CallAndWait
  1064. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" $(UNINSTALLING)
  1065. Call un.DeleteShotcutAndInstallInfo
  1066. IntOp $UnInstallValue $UnInstallValue + 8
  1067. GetFunctionAddress $0 un.RemoveFiles
  1068. BgWorker::CallAndWait
  1069. FunctionEnd
  1070. Function un.RemoveFiles
  1071. ${Locate} "$INSTDIR" "/G=0 /M=*.*" "un.onDeleteFileFound"
  1072. StrCpy $InstallState "1"
  1073. ; 卸载成功后创建标记文件
  1074. FileOpen $0 "$INSTDIR\install.flag" w
  1075. FileClose $0
  1076. ; 重启计算机
  1077. ; 创建任务计划程序命令
  1078. nsExec::ExecToStack 'schtasks /create /tn "DeleteInstallFlagTask" /tr "cmd.exe /C del $INSTDIR\install.flag" /sc onstart /ru System /rl HIGHEST /F'
  1079. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
  1080. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
  1081. Call un.initUninstallFinishPage
  1082. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTFINISH}
  1083. FunctionEnd
  1084. Function un.onDeleteFileFound
  1085. ; $R9 "path\name"
  1086. ; $R8 "path"
  1087. ; $R7 "name"
  1088. ; $R6 "size" ($R6 = "" if directory, $R6 = "0" if file with /S=)
  1089. ; MessageBox MB_OK "R9--------$R9"
  1090. ; MessageBox MB_OK "R8--------$R8"
  1091. ; MessageBox MB_OK "R7--------$R7"
  1092. ;不用保留场景
  1093. ${If} $sReserveData == 0
  1094. ${If} $R7 != "install.flag"
  1095. Delete "$R9"
  1096. RMDir /r "$R9"
  1097. RMDir "$R9"
  1098. ${EndIf}
  1099. ${EndIf}
  1100. ;保留场景
  1101. ${If} $sReserveData == 1
  1102. ${If} $R7 != "install.flag"
  1103. RMDir /r "$R8\bin"
  1104. RMDir /r "$R8\CGAII"
  1105. RMDir /r "$R8\mongodb"
  1106. RMDir /r "$R8\mysql"
  1107. RMDir /r "$R8\redis"
  1108. RMDir /r "$R8\jdk1.8"
  1109. ; RMDir /r "$R8\4DKK_PROGRAM_STATIC"
  1110. ; RMDir /r "$R8\4DKK_PROGRAM_DATA"
  1111. RMDir /r "$R8\tools"
  1112. Delete "$R8\uninst.exe"
  1113. ${EndIf}
  1114. ${EndIf}
  1115. IntOp $UnInstallValue $UnInstallValue + 2
  1116. ${If} $UnInstallValue > 100
  1117. IntOp $UnInstallValue 100 + 0
  1118. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
  1119. ${Else}
  1120. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "$UnInstallValue"
  1121. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_pos" "text" "$UnInstallValue%"
  1122. #Sleep 100
  1123. ${EndIf}
  1124. undelete:
  1125. Push "LocateNext"
  1126. FunctionEnd
  1127. #
  1128. # 以 Unicode 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
  1129. # 但建议 Unicode 版本优先使用此函数。
  1130. #
  1131. Function PathIsDBCS_W
  1132. Exch $R0
  1133. Push $R1
  1134. Push $R2
  1135. Push $R3
  1136. System::Call "*(&w${NSIS_MAX_STRLEN}R0)p.R1"
  1137. StrCpy $R0 0
  1138. StrCpy $R2 $R1
  1139. lbl_loop:
  1140. # Unicode 版取 2 个字节长度的字符,字符串遇到 0 字符表示结束了。
  1141. System::Call "*$R2(&i2.R3)"
  1142. IntCmp $R3 0 lbl_done
  1143. # Unicode 字符直接判断字符值,大于 128 的我们就视为非英文字符。
  1144. IntCmp $R3 128 0 lbl_skip
  1145. IntOp $R0 $R0 !
  1146. Goto lbl_done
  1147. lbl_skip:
  1148. # 如果用 NSIS 3.x 这里可以用 IntPtrOp 代替。
  1149. IntOp $R2 $R2 + 2
  1150. Goto lbl_loop
  1151. lbl_done:
  1152. System::Free $R1
  1153. Pop $R3
  1154. Pop $R2
  1155. Pop $R1
  1156. Exch $R0
  1157. FunctionEnd
  1158. #
  1159. # 以 ANSI 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
  1160. # 但建议 ANSI 版本优先使用此函数。
  1161. #
  1162. Function PathIsDBCS_A
  1163. Exch $R0
  1164. Push $R1
  1165. Push $R2
  1166. Push $R3
  1167. Push $R4
  1168. System::Call "*(&m${NSIS_MAX_STRLEN}R0)p.R1"
  1169. StrCpy $R0 0
  1170. StrCpy $R2 $R1
  1171. lbl_loop:
  1172. # ANSI 版取 1 个字节长度的字符,字符串遇到 0 字符表示结束了。
  1173. System::Call "*$R2(&i1.R3)"
  1174. IntCmp $R3 0 lbl_done
  1175. # ANSI 字符用 IsDBCSLeadByte 判断是否双字节字符的前导字节。
  1176. System::Call "kernel32::IsDBCSLeadByte(iR3)i.R4"
  1177. IntCmp $R4 0 lbl_skip
  1178. IntOp $R0 $R0 !
  1179. Goto lbl_done
  1180. lbl_skip:
  1181. # 用 CharNextA 得到下一个字符的地址 (可正确处理双字节字符)。
  1182. System::Call "user32::CharNextA(pR2)p.R2"
  1183. Goto lbl_loop
  1184. lbl_done:
  1185. Pop $R4
  1186. Pop $R3
  1187. Pop $R2
  1188. Pop $R1
  1189. Exch $R0
  1190. FunctionEnd
  1191. #
  1192. # 当选择的安装路径变更时,路径为空或包含双字节字符 (不限于简体中文),都不允许继续。
  1193. # 路径为空时,NSIS 会自行判断。
  1194. #
  1195. # 此示例未判断是否包含空格。如有需要,请与示例一配合使用。
  1196. #
  1197. Function onVerifyInstDir
  1198. # 检查安装路径是否包含双字节字符 (不限于简体中文)。
  1199. StrCpy $0 $INSTDIR
  1200. StrLen $1 $0
  1201. # 这里也可以换成 CheckEnglishPath 以测试效果。
  1202. ${If} $1 == 0
  1203. Push 2
  1204. ${Else}
  1205. Push $INSTDIR
  1206. Call PathIsDBCS_A
  1207. Pop $R0
  1208. Push $R0
  1209. ${endif}
  1210. lbl_done:
  1211. FunctionEnd
  1212. Function CheckEnglishPath
  1213. Exch $0 ; 保存返回值的变量
  1214. Exch ; 将字符串参数放在栈顶
  1215. Push $1
  1216. Push $2
  1217. Push $3
  1218. StrLen $1 $0 ; 计算字符串长度
  1219. loop:
  1220. StrCpy $2 $1 ; 复制当前长度
  1221. IntOp $1 $1 - 1 ; 长度减1
  1222. StrCpy $3 $0 1 $2 ; 获取当前字符
  1223. ${If} $3 == " " ; 如果字符是空格
  1224. Goto notEnglish ; 跳转到不是英文路径的逻辑
  1225. ${EndIf}
  1226. ${If} $1 > 0 ; 如果还有字符未检查
  1227. Goto loop ; 继续循环
  1228. ${EndIf}
  1229. ; 路径是全英文的
  1230. Pop $3
  1231. Pop $2
  1232. Pop $1
  1233. StrCpy $0 0
  1234. Exch $0
  1235. notEnglish:
  1236. ; 路径不是全英文的
  1237. Pop $3
  1238. Pop $2
  1239. Pop $1
  1240. StrCpy $0 1
  1241. Exch $0
  1242. FunctionEnd
  1243. Function onVerifySpecialInstDir
  1244. # 检查安装路径是否包含双字节字符 (不限于简体中文)。
  1245. StrCpy $0 $INSTDIR
  1246. StrLen $1 $0
  1247. # 这里也可以换成 PathIsDBCS_A 以测试效果。
  1248. ${If} $1 == 0
  1249. Push 2
  1250. ${Else}
  1251. Push $INSTDIR
  1252. Call CheckSpecialCharacters
  1253. Pop $0 ; 获取返回结果
  1254. Push $R0
  1255. ${endif}
  1256. FunctionEnd
  1257. Function CheckSpecialCharacters
  1258. Exch $0 ; 保存返回值的变量
  1259. Exch ; 将字符串参数放在栈顶
  1260. StrCpy $1 "!@#¥%……&*()!@#$%^&*()<>_+{}[];'?.,~`" ; 特殊字符
  1261. StrCpy $2 0 ; 特殊字符字符串索引
  1262. StrCpy $3 0 ; 字符串索引
  1263. StrLen $4 $0 ; 特殊字符字符串长度
  1264. loop:
  1265. StrCpy $5 $1 1 $2 ; 从特殊字符字符串中获取一个字符
  1266. StrCpy $6 $0 1 $3 ; 从需要检查的字符串中获取一个字符
  1267. StrCmp $5 "" done ; 如果特殊字符字符串已经检查完,跳转到 done
  1268. StrCmp $6 "" next ; 如果需要检查的字符串已经检查完,跳转到 next
  1269. StrCmp $5 $6 found ; 如果找到特殊字符,跳转到 found
  1270. IntOp $3 $3 + 1 ; 否则,增加需要检查的字符串的索引
  1271. Goto loop
  1272. next:
  1273. IntOp $2 $2 + 1 ; 增加特殊字符字符串的索引
  1274. StrCpy $3 0 ; 重置需要检查的字符串的索引
  1275. Goto loop
  1276. found:
  1277. StrCpy $0 "1"
  1278. Goto End
  1279. done:
  1280. StrCpy $0 "0"
  1281. end:
  1282. Exch $0 ; 将返回值出栈
  1283. FunctionEnd
  1284. Function isEmptyDir
  1285. # Stack -> # Stack: <directory>
  1286. Exch $0 # Stack: $0
  1287. Push $1 # Stack: $1, $0
  1288. FindFirst $0 $1 "$0\*.*"
  1289. strcmp $1 "." 0 _notempty
  1290. FindNext $0 $1
  1291. strcmp $1 ".." 0 _notempty
  1292. ClearErrors
  1293. FindNext $0 $1
  1294. IfErrors 0 _notempty
  1295. FindClose $0
  1296. Pop $1 # Stack: $0
  1297. StrCpy $0 1
  1298. Exch $0 # Stack: 1 (true)
  1299. goto _end
  1300. _notempty:
  1301. FindClose $0
  1302. ClearErrors
  1303. Pop $1 # Stack: $0
  1304. StrCpy $0 0
  1305. Exch $0 # Stack: 0 (false)
  1306. _end:
  1307. FunctionEnd
  1308. Function un.isEmptyDir
  1309. # Stack -> # Stack: <directory>
  1310. Exch $0 # Stack: $0
  1311. Push $1 # Stack: $1, $0
  1312. FindFirst $0 $1 "$0\*.*"
  1313. strcmp $1 "." 0 _notempty
  1314. FindNext $0 $1
  1315. strcmp $1 ".." 0 _notempty
  1316. ClearErrors
  1317. FindNext $0 $1
  1318. IfErrors 0 _notempty
  1319. FindClose $0
  1320. Pop $1 # Stack: $0
  1321. StrCpy $0 1
  1322. Exch $0 # Stack: 1 (true)
  1323. goto _end
  1324. _notempty:
  1325. FindClose $0
  1326. ClearErrors
  1327. Pop $1 # Stack: $0
  1328. StrCpy $0 0
  1329. Exch $0 # Stack: 0 (false)
  1330. _end:
  1331. FunctionEnd
  1332. Function initRegPage
  1333. nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_title" "bkimage" $(REG_TITLE)
  1334. nsNiuniuSkin::SetControlAttribute $hInstallDlg "install_info" "text" $(INSTALL_INFO)
  1335. nsNiuniuSkin::SetControlAttribute $hInstallDlg "machineCode" "text" $(MACHINE_CODE)
  1336. nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_machine_info" "text" $(REG_MACHINE_INFO)
  1337. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnCopyMachineinfo" "text" $(BTN_COPY_MACHINEINFO)
  1338. nsNiuniuSkin::SetControlAttribute $hInstallDlg "installKey" "text" $(INSTALL_KEY)
  1339. nsNiuniuSkin::SetControlAttribute $hInstallDlg "regPrompt" "text" $(REG_PROMPT)
  1340. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnRegConfirm" "text" $(BTN_REG_CONFIRM)
  1341. FunctionEnd
  1342. Function initConfigPage
  1343. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configPageTitle" "bkimage" $(CONFIG_PAGE_TITLE)
  1344. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPath" "text" $(CONFIG_INSTALL_PATH)
  1345. nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAgree" "text" $(CONFIG_CHK_AGREE)
  1346. ${If} $LANGUAGE == '1033'
  1347. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPath" "width" 115
  1348. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPathTip" "width" 310
  1349. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPathTip" "font" 11
  1350. ${ElseIf} $LANGUAGE == '1041'
  1351. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPath" "width" 100
  1352. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPathTip" "font" 5
  1353. nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAgree" "width" 190
  1354. ${ElseIf} $LANGUAGE == '1042'
  1355. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPath" "width" 70
  1356. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPathTip" "font" 5
  1357. ${ElseIf} $LANGUAGE == '2052'
  1358. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPath" "width" 60
  1359. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPathTip" "font" 5
  1360. ${EndIf}
  1361. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPathTip" "text" $(CONFIG_INSTALL_PATH_TIP)
  1362. nsNiuniuSkin::SetControlAttribute $hInstallDlg "configUseSpace" "text" $(CONFIG_USE_SPACE)
  1363. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnAgreement" "text" $(CONFIG_BTN_AGREEMENT)
  1364. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "text" $(CONFIG_BTN_INSTALL)
  1365. FunctionEnd
  1366. Function initLicensePage
  1367. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnAgree" "text" $(LICENSE_BTN_AGREE)
  1368. FunctionEnd
  1369. Function initInstallingPage
  1370. nsNiuniuSkin::SetControlAttribute $hInstallDlg "InstallingTitle" "bkimage" $(INSTALLING_TITLE)
  1371. FunctionEnd
  1372. Function initFinishPage
  1373. nsNiuniuSkin::SetControlAttribute $hInstallDlg "FinishPageTitle" "bkimage" $(FINISH_PAGE_TITLE)
  1374. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnRun" "text" $(BTN_RUN)
  1375. FunctionEnd
  1376. Function un.initUnInstallPage
  1377. nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallTitle" "bkimage" $(UN_INSTALL_TITLE)
  1378. nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallPrompt" "text" $(UN_INSTALL_PROMPT)
  1379. nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkbox_userdata" "text" $(UN_INSTALL_CHKBOX_USERDATA)
  1380. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUnInstall" "text" $(BTN_CONFIRM)
  1381. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUnClose" "text" $(BTN_CANCEL)
  1382. FunctionEnd
  1383. Function un.initUninstallingPage
  1384. nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallingTitle" "bkimage" $(UN_INSTALL_TITLE)
  1385. FunctionEnd
  1386. Function un.initUninstallFinishPage
  1387. nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallFinishTitle" "bkimage" $(UN_INSTALL_TITLE)
  1388. nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallFinishPrompt" "text" $(UN_INSTALL_FINISH_PROMPT)
  1389. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUninstalled" "text" $(BTN_UNINSTALLED)
  1390. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUninstalledReboot" "text" $(BTN_UNINSTALLED_REBOOT)
  1391. FunctionEnd