ui_laser_setup.nsh 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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 "MUI.nsh"
  11. !include "WinVer.nsh"
  12. !include "commonfunc.nsh"
  13. !insertmacro MUI_LANGUAGE "SimpChinese"
  14. VIProductVersion "${PRODUCT_VERSION}"
  15. VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
  16. VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
  17. VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
  18. VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
  19. VIAddVersionKey "InternalName" "${EXE_NAME}"
  20. VIAddVersionKey "FileDescription" "${PRODUCT_NAME}"
  21. VIAddVersionKey "LegalCopyright" "${PRODUCT_LEGAL}"
  22. !define INSTALL_PAGE_CONFIG 0
  23. ;!define INSTALL_PAGE_LICENSE 1
  24. !define INSTALL_PAGE_PROCESSING 1
  25. !define INSTALL_PAGE_FINISH 2
  26. !define INSTALL_PAGE_UNISTCONFIG 3
  27. !define INSTALL_PAGE_UNISTPROCESSING 4
  28. !define INSTALL_PAGE_UNISTFINISH 5
  29. Page custom DUIPage
  30. UninstPage custom un.DUIPage
  31. Var hInstallDlg
  32. Var hInstallSubDlg
  33. Var sCmdFlag
  34. Var sCmdSetupPath
  35. Var sSetupPath
  36. Var sReserveData
  37. Var InstallState
  38. Var UnInstallValue
  39. Var basedir
  40. Var datadir
  41. Var logError
  42. Var buildModelPath
  43. Var profilePath
  44. Var buildCallPath
  45. Var dbpath
  46. Var logpath
  47. Var binPath
  48. Var javaPath
  49. Var temp11
  50. Var temp12
  51. Var OLD_VER
  52. Var step
  53. ;在安装程序运行前的回调函数前实现
  54. Function .onInit
  55. System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
  56. Pop $R0
  57. StrCmp $R0 0 +3
  58. MessageBox MB_OK|MB_USERICON '有一个安装向导已经运行,请勿重复打开'
  59. Abort
  60. ${IfNot} ${AtLeastWin10}
  61. MessageBox MB_OK|MB_USERICON '本程序只能安装在windows-10(64位)系统上'
  62. Abort
  63. ${EndIf}
  64. ReadRegStr $OLD_VER HKLM "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
  65. ${IF} $OLD_VER != ""
  66. ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
  67. ${If} $R0 == "0"
  68. MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  69. Quit
  70. ${EndIf}
  71. ${If} $R0 == "1"
  72. MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  73. ;MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},您安装的版本是 ${PRODUCT_VERSION} 小于版本 $OLD_VER '
  74. Quit
  75. ${EndIf}
  76. ${If} $R0 == "2"
  77. MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  78. ;MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},您安装的版本是 ${PRODUCT_VERSION} 大于版本 $OLD_VER '
  79. Quit
  80. ${EndIf}
  81. ${EndIf}
  82. FunctionEnd
  83. Function un.onInit
  84. System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
  85. Pop $R0
  86. StrCmp $R0 0 +3
  87. MessageBox MB_OK|MB_USERICON '有一个卸载向导已经运行,请勿重复打开'
  88. Abort
  89. FunctionEnd
  90. Function DUIPage
  91. StrCpy $InstallState "0"
  92. InitPluginsDir
  93. SetOutPath "$PLUGINSDIR"
  94. File "${INSTALL_LICENCE_FILENAME}"
  95. File "${INSTALL_RES_PATH}"
  96. File /oname=logo.ico "${INSTALL_ICO}" #
  97. nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" "${INSTALL_LICENCE_FILENAME}"
  98. Pop $hInstallDlg
  99. Call GenerateSetupAddress
  100. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
  101. Call OnRichEditTextChange
  102. nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}安装程序"
  103. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
  104. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licensename" "text" "《四维深时本地版用户许可协议》"
  105. Call BindUIControls
  106. nsNiuniuSkin::ShowPage 0
  107. FunctionEnd
  108. Function un.DUIPage
  109. StrCpy $InstallState "0"
  110. InitPluginsDir
  111. SetOutPath "$PLUGINSDIR"
  112. File "${INSTALL_RES_PATH}"
  113. File /oname=logo.ico "${UNINSTALL_ICO}"
  114. nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" ""
  115. Pop $hInstallDlg
  116. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTCONFIG}
  117. nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}卸载程序"
  118. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390s
  119. Call un.BindUnInstUIControls
  120. nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAutoRun" "selected" "true"
  121. nsNiuniuSkin::ShowPage 0
  122. FunctionEnd
  123. Function un.BindUnInstUIControls
  124. GetFunctionAddress $0 un.ExitDUISetup
  125. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUninstalled" $0
  126. GetFunctionAddress $0 un.onUninstall
  127. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUnInstall" $0
  128. GetFunctionAddress $0 un.ExitDUISetup
  129. nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
  130. GetFunctionAddress $0 un.OnBtnMin
  131. nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
  132. GetFunctionAddress $0 un.BtnDirPre
  133. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
  134. FunctionEnd
  135. Function BindUIControls
  136. GetFunctionAddress $0 OnExitDUISetup
  137. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseClose" $0
  138. GetFunctionAddress $0 OnBtnMin
  139. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseMin" $0
  140. GetFunctionAddress $0 OnBtnLicenseClick
  141. nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgreement" $0
  142. GetFunctionAddress $0 OnExitDUISetup
  143. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirClose" $0
  144. GetFunctionAddress $0 OnExitDUISetup
  145. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseCancel" $0
  146. GetFunctionAddress $0 OnBtnMin
  147. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirMin" $0
  148. GetFunctionAddress $0 OnBtnSelectDir
  149. nsNiuniuSkin::BindCallBack $hInstallDlg "btnSelectDir" $0
  150. GetFunctionAddress $0 OnBtnDirPre
  151. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
  152. GetFunctionAddress $0 OnBtnShowConfig
  153. nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgree" $0
  154. GetFunctionAddress $0 OnBtnCancel
  155. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirCancel" $0
  156. GetFunctionAddress $0 OnBtnInstall
  157. nsNiuniuSkin::BindCallBack $hInstallDlg "btnInstall" $0
  158. GetFunctionAddress $0 OnExitDUISetup
  159. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailClose" $0
  160. GetFunctionAddress $0 OnBtnMin
  161. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailMin" $0
  162. GetFunctionAddress $0 OnFinished
  163. nsNiuniuSkin::BindCallBack $hInstallDlg "btnRun" $0
  164. GetFunctionAddress $0 OnBtnMin
  165. nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
  166. GetFunctionAddress $0 OnExitDUISetup
  167. nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
  168. GetFunctionAddress $0 OnCheckLicenseClick
  169. nsNiuniuSkin::BindCallBack $hInstallDlg "chkAgree" $0
  170. GetFunctionAddress $0 OnBtnShowMore
  171. nsNiuniuSkin::BindCallBack $hInstallDlg "btnShowMore" $0
  172. GetFunctionAddress $0 OnBtnHideMore
  173. nsNiuniuSkin::BindCallBack $hInstallDlg "btnHideMore" $0
  174. GetFunctionAddress $0 OnSysCommandCloseEvent
  175. nsNiuniuSkin::BindCallBack $hInstallDlg "syscommandclose" $0
  176. GetFunctionAddress $0 OnRichEditTextChange
  177. nsNiuniuSkin::BindCallBack $hInstallDlg "editDir" $0
  178. FunctionEnd
  179. Function OnRichEditTextChange
  180. nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
  181. Pop $0
  182. StrCpy $INSTDIR "$0"
  183. Call onVerifyInstDir
  184. Pop $0
  185. ${If} $0 == 1
  186. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "不能包含中文路径"
  187. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  188. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  189. goto TextChangeAbort
  190. ${EndIf}
  191. ${If} $0 == 2
  192. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "路径不能为空"
  193. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  194. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  195. goto TextChangeAbort
  196. ${EndIf}
  197. Call IsSetupPathIlleagal
  198. ${If} $R5 == "0"
  199. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "路径错误"
  200. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  201. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  202. goto TextChangeAbort
  203. ${EndIf}
  204. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#FF999999"
  205. ${If} $R0 > 1024
  206. IntOp $R1 $R0 % 1024
  207. IntOp $R0 $R0 / 1024;
  208. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "剩余空间:$R0.$R1GB"
  209. ${Else}
  210. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "剩余空间:$R0.$R1MB"
  211. ${endif}
  212. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  213. Pop $0
  214. ${If} $0 == "1"
  215. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  216. ${Else}
  217. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  218. ${EndIf}
  219. TextChangeAbort:
  220. FunctionEnd
  221. Function OnCheckLicenseClick
  222. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  223. Pop $0
  224. ${If} $0 == "0"
  225. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  226. ${Else}
  227. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  228. ${EndIf}
  229. FunctionEnd
  230. Function OnBtnLicenseClick
  231. ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_LICENSE}
  232. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "true"
  233. nsNiuniuSkin::GetControlAttribute $hInstallDlg "moreconfiginfo" "visible"
  234. Pop $0
  235. ${If} $0 = 0
  236. ;pos="10,35,560,405"
  237. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,385"
  238. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "270"
  239. ${Else}
  240. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,495"
  241. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "375"
  242. ${EndIf}
  243. FunctionEnd
  244. Section "silentInstallSec" SEC01
  245. #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent install code here."
  246. SectionEnd
  247. Function ShowMsgBox
  248. nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
  249. Pop $hInstallSubDlg
  250. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" "提示"
  251. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
  252. ${If} "$R7" == "1"
  253. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
  254. ${EndIf}
  255. nsNiuniuSkin::ShowSkinSubPage 0
  256. FunctionEnd
  257. Function OnBtnInstall
  258. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  259. Pop $0
  260. StrCpy $0 "1"
  261. StrCmp $0 "0" InstallAbort 0
  262. nsProcess::_FindProcess "${EXE_NAME_EXT}"
  263. Pop $R0
  264. ${If} $R0 == 0
  265. StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
  266. StrCpy $R7 "0"
  267. Call ShowMsgBox
  268. goto InstallAbort
  269. ${EndIf}
  270. nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
  271. Pop $0
  272. StrCmp $0 "" InstallAbort 0
  273. Call AdjustInstallPath
  274. StrCpy $sSetupPath "$INSTDIR"
  275. Call IsSetupPathIlleagal
  276. ${If} $R5 == "0"
  277. StrCpy $R8 "路径错误,请使用正确的路径安装!"
  278. StrCpy $R7 "0"
  279. Call ShowMsgBox
  280. goto InstallAbort
  281. ${EndIf}
  282. ${If} $R5 == "-1"
  283. StrCpy $R8 "目标磁盘空间不足,请使用其他的磁盘安装!"
  284. StrCpy $R7 "0"
  285. Call ShowMsgBox
  286. goto InstallAbort
  287. ${EndIf}
  288. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
  289. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
  290. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_PROCESSING}
  291. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "min" "0"
  292. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "max" "100"
  293. #Call BakFiles
  294. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在安装"
  295. GetFunctionAddress $0 ExtractFunc
  296. BgWorker::CallAndWait
  297. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkShotcut" "selected"
  298. #Pop $R0
  299. # ${If} $R0 == "1"
  300. # SetShellVarContext all
  301. # CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
  302. # SetShellVarContext current
  303. # ${EndIf}
  304. SetShellVarContext all
  305. CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
  306. SetShellVarContext current
  307. Call CreateAppShortcut
  308. Call CreateUninstall
  309. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
  310. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在初始化..."
  311. GetFunctionAddress $0 OnEnvInstall
  312. BgWorker::CallAndWait
  313. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在初始化服务..."
  314. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" ""
  315. GetFunctionAddress $0 installService
  316. BgWorker::CallAndWait
  317. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "初始化完成"
  318. StrCpy $InstallState "1"
  319. #Call OnFinished
  320. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_FINISH}
  321. InstallAbort:
  322. FunctionEnd
  323. Function ExtractCallback
  324. Pop $1
  325. Pop $2
  326. System::Int64Op $1 * 100
  327. Pop $3
  328. System::Int64Op $3 / $2
  329. Pop $0
  330. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "$0"
  331. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "$0%"
  332. ${If} $1 == $2
  333. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "100"
  334. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "100%"
  335. ${EndIf}
  336. FunctionEnd
  337. Function OnSysCommandCloseEvent
  338. Call OnExitDUISetup
  339. FunctionEnd
  340. Function OnExitDUISetup
  341. ${If} $InstallState == "0"
  342. StrCpy $R8 "确定要停止安装吗?"
  343. StrCpy $R7 "1"
  344. Call ShowMsgBox
  345. pop $0
  346. ${If} $0 == 0
  347. goto endfun
  348. ${EndIf}
  349. ${EndIf}
  350. nsNiuniuSkin::ExitDUISetup
  351. endfun:
  352. FunctionEnd
  353. Function OnBtnMin
  354. SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
  355. FunctionEnd
  356. Function OnBtnCancel
  357. nsNiuniuSkin::ExitDUISetup
  358. FunctionEnd
  359. Function OnEnvInstall
  360. EnVar::SetHKLM
  361. EnVar::AddValue FDMGEA_HOME "$INSTDIR"
  362. ;EnVar::SetHKLM
  363. ;EnVar::AddValue JAVA_HOME "$INSTDIR\jdk1.8"
  364. EnVar::SetHKLM
  365. EnVar::AddValue MYSQL_HOME "$INSTDIR\mysql"
  366. EnVar::SetHKLM
  367. EnVar::AddValue REDIS_HOME "$INSTDIR\redis"
  368. EnVar::SetHKLM
  369. EnVar::AddValue 4DKK_HOME "$INSTDIR\CGAII"
  370. EnVar::SetHKLM
  371. EnVar::AddValue MONGODB_HOME "$INSTDIR\mongodb"
  372. ;EnVar::SetHKLM
  373. ;EnVar::AddValue CLASS_PATH ".;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
  374. EnVar::SetHKLM
  375. ;EnVar::AddValue "Path" "$INSTDIR\jdk1.8\bin;$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;"
  376. EnVar::AddValue "Path" "$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;"
  377. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  378. ;nsExec::ExecToStack '"$INSTDIR\tools\env_install.bat" $INSTDIR '
  379. FunctionEnd
  380. Function un.OnEnvDownInstall
  381. EnVar::SetHKLM
  382. EnVar::Delete "FDMGEA_HOME" "$INSTDIR"
  383. ;EnVar::Delete "JAVA_HOME" "$INSTDIR\jdk1.8"
  384. EnVar::Delete "MYSQL_HOME" "$INSTDIR\mysql"
  385. EnVar::Delete "REDIS_HOME" "$INSTDIR\redis"
  386. EnVar::Delete "4DKK_HOME" "$INSTDIR\CGAII"
  387. EnVar::Delete "MONGODB_HOME" "$INSTDIR\mongodb"
  388. ;EnVar::Delete "CLASS_PATH" "%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
  389. ;EnVar::DeleteValue "PATH" "%JAVA_HOME%\bin"
  390. EnVar::DeleteValue "PATH" "$INSTDIR\mysql\bin"
  391. EnVar::DeleteValue "PATH" "$INSTDIR\mongodb\bin"
  392. EnVar::DeleteValue "PATH" "$INSTDIR\redis"
  393. EnVar::DeleteValue "PATH" "$INSTDIR\CGAII"
  394. EnVar::DeleteValue "PATH" "$INSTDIR\CGAII\lib"
  395. ;nsExec::ExecToStack '"$INSTDIR\tools\uninstall.bat" $INSTDIR '
  396. FunctionEnd
  397. Function un.installService
  398. ${If} $sReserveData == 1
  399. ; CreateDirectory $INSTDIR\USER_DATA\static
  400. ; CreateDirectory $INSTDIR\USER_DATA\pro
  401. ;CopyFiles /SILENT $INSTDIR\4DKK_PROGRAM_STATIC\*.* $INSTDIR\USER_DATA\static
  402. ;CopyFiles /SILENT $INSTDIR\4DKK_PROGRAM_DATA\*.* $INSTDIR\USER_DATA\pro
  403. ${EndIf}
  404. nsExec::ExecToStack '"$INSTDIR\tools\unservice.bat" $INSTDIR '
  405. SimpleSC::ExistsService "lasermongodb"
  406. Pop $0
  407. ${If} $0 == 0
  408. SimpleSC::StopService "lasermongodb" 0 30
  409. SimpleSC::RemoveService "lasermongodb"
  410. ${EndIf}
  411. SimpleSC::ExistsService "lasermysql"
  412. Pop $0
  413. ${If} $0 == 0
  414. SimpleSC::StopService "lasermysql" 0 30
  415. SimpleSC::RemoveService "lasermysql"
  416. ${EndIf}
  417. SimpleSC::ExistsService "laserredis"
  418. Pop $0
  419. ${If} $0 == 0
  420. SimpleSC::StopService "laserredis" 0 30
  421. SimpleSC::RemoveService "laserredis"
  422. ${EndIf}
  423. SimpleSC::ExistsService "checkLaserProcess"
  424. Pop $0
  425. ${If} $0 == 0
  426. SimpleSC::StopService "checkLaserProcess" 0 30
  427. SimpleSC::RemoveService "checkLaserProcess"
  428. ${EndIf}
  429. FunctionEnd
  430. Function installService
  431. ${StrRep} $0 '$INSTDIR\mysql' '\' '\\'
  432. StrCpy $basedir $0
  433. ${StrRep} $0 '$INSTDIR\mysql\data' '\' '\\'
  434. StrCpy $datadir $0
  435. ${StrRep} $0 '$INSTDIR\mysql\logs.log' '\' '\\'
  436. StrCpy $logError $0
  437. WriteINIStr $INSTDIR\mysql\my.ini mysqld port 3307
  438. WriteINIStr $INSTDIR\mysql\my.ini mysqld basedir $basedir
  439. WriteINIStr $INSTDIR\mysql\my.ini mysqld datadir $datadir
  440. WriteINIStr $INSTDIR\mysql\my.ini mysqld log-error $logError
  441. WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connections 1000
  442. WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connect_errors 10
  443. WriteINIStr $INSTDIR\mysql\my.ini mysqld character-set-server utf8mb4
  444. WriteINIStr $INSTDIR\mysql\my.ini mysqld default-storage-engine INNODB
  445. WriteINIStr $INSTDIR\mysql\my.ini mysqld default_authentication_plugin mysql_native_password
  446. WriteINIStr $INSTDIR\mysql\my.ini mysqld local_infile ON
  447. WriteINIStr $INSTDIR\mysql\my.ini mysql default-character-set utf8mb4
  448. WriteINIStr $INSTDIR\mysql\my.ini mysql local_infile ON
  449. WriteINIStr $INSTDIR\mysql\my.ini client port 3307
  450. WriteINIStr $INSTDIR\mysql\my.ini client default-character-set utf8mb4
  451. Sleep 2000
  452. SetOutPath "$INSTDIR\mysql\bin"
  453. Sleep 2000
  454. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --initialize-insecure --lower-case-table-names=1'
  455. Pop $0
  456. Pop $1
  457. ${If} $0 = 0
  458. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
  459. ${Else}
  460. ;MessageBox mb_ok "code=$0,mes=$1"
  461. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\VC_redist.x64.exe /install /quiet /norestart'
  462. Sleep 2000
  463. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --initialize-insecure --lower-case-table-names=1'
  464. Sleep 2000
  465. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
  466. ${EndIf}
  467. nsExec::ExecToStack '"cmd.exe" /c powercfg.exe /hibernate off '
  468. SimpleSC::StartService "lasermysql" "" 30
  469. SetOutPath "$INSTDIR\redis"
  470. nsExec::ExecToStack '"cmd.exe" /c redis-server.exe --service-install "$INSTDIR\redis\redis.windows.conf" --service-name laserredis --loglevel verbose'
  471. SimpleSC::StartService "laserredis" "" 30
  472. nsExec::ExecToStack '"cmd.exe" /c sc config laserredis start=auto'
  473. SimpleSC::RestartService "laserredis" "" 30
  474. Sleep 2000
  475. SetOutPath "$INSTDIR\mongodb"
  476. ${StrRep} $0 '$INSTDIR\mongodb\db' '\' '\\'
  477. StrCpy $dbpath $0
  478. ${StrRep} $0 '$INSTDIR\mongodb\logs\mongo.log' '\' '\\'
  479. StrCpy $logpath $0
  480. FileOpen $0 $INSTDIR\mongodb\mongo.conf w
  481. IfErrors done
  482. FileWrite $0 'port=29031$\n'
  483. FileWrite $0 'dbpath=$dbpath$\n'
  484. FileWrite $0 'logpath=$logpath$\n'
  485. FileWrite $0 'logappend=true$\n'
  486. FileWrite $0 'maxConns=1000$\n'
  487. FileClose $0
  488. done:
  489. nsExec::ExecToStack '"cmd.exe" /c sc create lasermongodb binpath= "$INSTDIR\mongodb\bin\mongod.exe --config $INSTDIR\mongodb\mongo.conf --service" start= auto'
  490. SimpleSC::StartService "lasermongodb" "" 30
  491. Sleep 2000
  492. ; IfFileExists "$INSTDIR\USER_DATA\static\*.*" 0 static_not_found
  493. ; CopyFiles /SILENT $INSTDIR\USER_DATA\static\*.* $INSTDIR\4DKK_PROGRAM_STATIC
  494. ; RMDir /r "$INSTDIR\USER_DATA\static"
  495. ; goto static_end_of
  496. ; static_not_found:
  497. ; goto static_end_of
  498. ; static_end_of:
  499. ; IfFileExists "$INSTDIR\USER_DATA\pro\*.*" 0 pro_not_found
  500. ; CopyFiles /SILENT $INSTDIR\USER_DATA\pro\*.* $INSTDIR\4DKK_PROGRAM_DATA
  501. ; RMDir /r "$INSTDIR\USER_DATA\pro"
  502. ; goto pro_end_of
  503. ; pro_not_found:
  504. ; goto pro_end_of
  505. ; pro_end_of:
  506. Sleep 2000
  507. ;
  508. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_DATA\' '\' '\\'
  509. StrCpy $buildModelPath $0
  510. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_STATIC\' '\' '\\'
  511. StrCpy $profilePath $0
  512. ${StrRep} $0 '$INSTDIR\CGAII' '\' '\\'
  513. StrCpy $buildCallPath $0
  514. ${StrRep} $0 '$INSTDIR\bin\resources\static' '\' '\\'
  515. StrCpy $binPath $0
  516. ${StrRep} $0 '$INSTDIR\jdk1.8\bin\java.exe' '\' '\\'
  517. StrCpy $javaPath $0
  518. nsJSON::Set /file $INSTDIR\bin\resources\static\setting.json
  519. nsJSON::Set /value `{}`
  520. nsJSON::Set `sceneConfig` /value `"config.json"`
  521. nsJSON::Set `sceheKey` /value `"id"`
  522. nsJSON::Set `sceneBundle` /value `"./build.zip"`
  523. nsJSON::Set `sceneBundleDir` /value `"capture"`
  524. nsJSON::Set `buildModelPath` /value `"$buildModelPath"`
  525. nsJSON::Set `javaPort` /value `9000`
  526. nsJSON::Set `javaPath` /value `"$javaPath"`
  527. nsJSON::Set `profilePath` /value `"$profilePath"`
  528. nsJSON::Set `buildCallPath` /value `"$buildCallPath"`
  529. nsJSON::Set `binPath` /value `"$binPath"`
  530. nsJSON::Serialize /format /file $INSTDIR\bin\resources\static\setting.json
  531. nsExec::ExecToStack '"$INSTDIR\tools\service.bat" $INSTDIR '
  532. nsExec::ExecToStack '"$INSTDIR\tools\update.bat" $INSTDIR '
  533. ; FileOpen $0 $INSTDIR\bin\resources\static\4dmega.vmoptions w
  534. ; IfErrors done
  535. ; FileWrite $0 '-DBIN_PATH=$INSTDIR\bin\resources\static$\n'
  536. ; FileWrite $0 '-DPROFILE_PATH=$INSTDIR\4DKK_PROGRAM_STATIC\$\n'
  537. ; FileWrite $0 '-DBUILD_MODEL_PATH=$INSTDIR\4DKK_PROGRAM_DATA\$\n'
  538. ; FileWrite $0 '-DBUILD_CALL_PATH=$INSTDIR\CGAII\$\n'
  539. ; FileWrite $0 '-Dspring.profiles.active=standAloneProd$\n'
  540. ; FileWrite $0 '-Dserver.port=9000$\n'
  541. ; FileClose $0
  542. ; done:
  543. nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\tools\MonitorPid.exe install '
  544. functionend
  545. Function OnFinished
  546. #MessageBox MB_YESNO|MB_ICONQUESTION "需要重启系统才能完成安装" IDNO +2
  547. #Reboot
  548. #Exec "$INSTDIR${EXE_NAME}"
  549. Call OnExitDUISetup
  550. FunctionEnd
  551. Function OnBtnSelectDir
  552. nsNiuniuSkin::SelectInstallDirEx $hInstallDlg "请选择安装路径"
  553. Pop $0
  554. ${Unless} "$0" == ""
  555. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" $0
  556. ${EndUnless}
  557. FunctionEnd
  558. Function StepHeightSizeAsc
  559. ${ForEach} $R0 390 500 + 10
  560. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
  561. Sleep 5
  562. ${Next}
  563. FunctionEnd
  564. Function StepHeightSizeDsc
  565. ${ForEach} $R0 480 390 - 10
  566. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
  567. Sleep 5
  568. ${Next}
  569. FunctionEnd
  570. Function OnBtnShowMore
  571. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
  572. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
  573. nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "true"
  574. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "true"
  575. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "false"
  576. GetFunctionAddress $0 StepHeightSizeAsc
  577. BgWorker::CallAndWait
  578. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 500
  579. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
  580. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
  581. FunctionEnd
  582. Function OnBtnHideMore
  583. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
  584. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
  585. nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "false"
  586. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "false"
  587. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "true"
  588. GetFunctionAddress $0 StepHeightSizeDsc
  589. BgWorker::CallAndWait
  590. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
  591. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
  592. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
  593. FunctionEnd
  594. Function OnBtnShowConfig
  595. ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
  596. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "false"
  597. FunctionEnd
  598. Function OnBtnDirPre
  599. StrCpy $R8 "确定要取消四维深时本地版安装吗?"
  600. StrCpy $R7 "0"
  601. Call ShowMsgBox
  602. ;nsNiuniuSkin::PrePage "wizardTab"
  603. FunctionEnd
  604. Function un.BtnDirPre
  605. StrCpy $R8 "确定要取消四维深时本地版卸载吗?"
  606. StrCpy $R7 "0"
  607. Call un.ShowMsgBox
  608. ;nsNiuniuSkin::PrePage "wizardTab"
  609. FunctionEnd
  610. Function un.ShowMsgBox
  611. nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
  612. Pop $hInstallSubDlg
  613. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" "提示"
  614. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
  615. ${If} "$R7" == "1"
  616. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
  617. ${EndIf}
  618. nsNiuniuSkin::ShowSkinSubPage 0
  619. FunctionEnd
  620. Function un.ExitDUISetup
  621. nsNiuniuSkin::ExitDUISetup
  622. FunctionEnd
  623. Function un.OnBtnMin
  624. SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
  625. FunctionEnd
  626. Section "un.silentInstallSec" SEC02
  627. #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent uninstall code here."
  628. SectionEnd
  629. Function un.onUninstall
  630. nsProcess::_FindProcess "${EXE_NAME_EXT}"
  631. Pop $R0
  632. ${If} $R0 == 0
  633. StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
  634. StrCpy $R7 "0"
  635. Call un.ShowMsgBox
  636. goto InstallAbort
  637. ${EndIf}
  638. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkbox_userdata" "selected"
  639. Pop $0
  640. StrCpy $sReserveData $0
  641. ${If} $sReserveData == 1
  642. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在准备卸载..."
  643. CreateDirectory $INSTDIR\USER_DATA
  644. ${EndIf}
  645. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
  646. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTPROCESSING}
  647. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "min" "0"
  648. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "max" "100"
  649. IntOp $UnInstallValue 0 + 1
  650. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在准备卸载..."
  651. GetFunctionAddress $0 un.OnEnvDownInstall
  652. BgWorker::CallAndWait
  653. nsExec::ExecToStack 'cmd.exe /c powercfg.exe /hibernate on '
  654. GetFunctionAddress $0 un.installService
  655. BgWorker::CallAndWait
  656. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在卸载..."
  657. Call un.DeleteShotcutAndInstallInfo
  658. IntOp $UnInstallValue $UnInstallValue + 8
  659. GetFunctionAddress $0 un.RemoveFiles
  660. BgWorker::CallAndWait
  661. InstallAbort:
  662. FunctionEnd
  663. Function un.RemoveFiles
  664. ${Locate} "$INSTDIR" "/G=0 /M=*.*" "un.onDeleteFileFound"
  665. StrCpy $InstallState "1"
  666. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
  667. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
  668. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTFINISH}
  669. FunctionEnd
  670. Function un.onDeleteFileFound
  671. ; $R9 "path\name"
  672. ; $R8 "path"
  673. ; $R7 "name"
  674. ; $R6 "size" ($R6 = "" if directory, $R6 = "0" if file with /S=)
  675. ${If} $sReserveData == 0
  676. Delete "$R9"
  677. RMDir /r "$R9"
  678. RMDir "$R9"
  679. ${EndIf}
  680. ${If} $sReserveData == 1
  681. RMDir /r "$R8\bin"
  682. RMDir /r "$R8\CGAII"
  683. RMDir /r "$R8\mongodb"
  684. RMDir /r "$R8\mysql"
  685. RMDir /r "$R8\redis"
  686. RMDir /r "$R8\jdk1.8"
  687. ; RMDir /r "$R8\4DKK_PROGRAM_STATIC"
  688. ; RMDir /r "$R8\4DKK_PROGRAM_DATA"
  689. RMDir /r "$R8\tools"
  690. Delete "$R8\uninst.exe"
  691. ${EndIf}
  692. IntOp $UnInstallValue $UnInstallValue + 2
  693. ${If} $UnInstallValue > 100
  694. IntOp $UnInstallValue 100 + 0
  695. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
  696. ${Else}
  697. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "$UnInstallValue"
  698. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_pos" "text" "$UnInstallValue%"
  699. #Sleep 100
  700. ${EndIf}
  701. undelete:
  702. Push "LocateNext"
  703. FunctionEnd
  704. #
  705. # 以 Unicode 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
  706. # 但建议 Unicode 版本优先使用此函数。
  707. #
  708. Function PathIsDBCS_W
  709. Exch $R0
  710. Push $R1
  711. Push $R2
  712. Push $R3
  713. System::Call "*(&w${NSIS_MAX_STRLEN}R0)p.R1"
  714. StrCpy $R0 0
  715. StrCpy $R2 $R1
  716. lbl_loop:
  717. # Unicode 版取 2 个字节长度的字符,字符串遇到 0 字符表示结束了。
  718. System::Call "*$R2(&i2.R3)"
  719. IntCmp $R3 0 lbl_done
  720. # Unicode 字符直接判断字符值,大于 128 的我们就视为非英文字符。
  721. IntCmp $R3 128 0 lbl_skip
  722. IntOp $R0 $R0 !
  723. Goto lbl_done
  724. lbl_skip:
  725. # 如果用 NSIS 3.x 这里可以用 IntPtrOp 代替。
  726. IntOp $R2 $R2 + 2
  727. Goto lbl_loop
  728. lbl_done:
  729. System::Free $R1
  730. Pop $R3
  731. Pop $R2
  732. Pop $R1
  733. Exch $R0
  734. FunctionEnd
  735. #
  736. # 以 ANSI 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
  737. # 但建议 ANSI 版本优先使用此函数。
  738. #
  739. Function PathIsDBCS_A
  740. Exch $R0
  741. Push $R1
  742. Push $R2
  743. Push $R3
  744. Push $R4
  745. System::Call "*(&m${NSIS_MAX_STRLEN}R0)p.R1"
  746. StrCpy $R0 0
  747. StrCpy $R2 $R1
  748. lbl_loop:
  749. # ANSI 版取 1 个字节长度的字符,字符串遇到 0 字符表示结束了。
  750. System::Call "*$R2(&i1.R3)"
  751. IntCmp $R3 0 lbl_done
  752. # ANSI 字符用 IsDBCSLeadByte 判断是否双字节字符的前导字节。
  753. System::Call "kernel32::IsDBCSLeadByte(iR3)i.R4"
  754. IntCmp $R4 0 lbl_skip
  755. IntOp $R0 $R0 !
  756. Goto lbl_done
  757. lbl_skip:
  758. # 用 CharNextA 得到下一个字符的地址 (可正确处理双字节字符)。
  759. System::Call "user32::CharNextA(pR2)p.R2"
  760. Goto lbl_loop
  761. lbl_done:
  762. Pop $R4
  763. Pop $R3
  764. Pop $R2
  765. Pop $R1
  766. Exch $R0
  767. FunctionEnd
  768. #
  769. # 当选择的安装路径变更时,路径为空或包含双字节字符 (不限于简体中文),都不允许继续。
  770. # 路径为空时,NSIS 会自行判断。
  771. #
  772. # 此示例未判断是否包含空格。如有需要,请与示例一配合使用。
  773. #
  774. Function onVerifyInstDir
  775. # 检查安装路径是否包含双字节字符 (不限于简体中文)。
  776. StrCpy $0 $INSTDIR
  777. StrLen $1 $0
  778. # 这里也可以换成 PathIsDBCS_A 以测试效果。
  779. ${If} $1 == 0
  780. Push 2
  781. ${Else}
  782. Push $INSTDIR
  783. Call PathIsDBCS_A
  784. Pop $R0
  785. Push $R0
  786. ${endif}
  787. lbl_done:
  788. FunctionEnd
  789. Function isEmptyDir
  790. # Stack -> # Stack: <directory>
  791. Exch $0 # Stack: $0
  792. Push $1 # Stack: $1, $0
  793. FindFirst $0 $1 "$0\*.*"
  794. strcmp $1 "." 0 _notempty
  795. FindNext $0 $1
  796. strcmp $1 ".." 0 _notempty
  797. ClearErrors
  798. FindNext $0 $1
  799. IfErrors 0 _notempty
  800. FindClose $0
  801. Pop $1 # Stack: $0
  802. StrCpy $0 1
  803. Exch $0 # Stack: 1 (true)
  804. goto _end
  805. _notempty:
  806. FindClose $0
  807. ClearErrors
  808. Pop $1 # Stack: $0
  809. StrCpy $0 0
  810. Exch $0 # Stack: 0 (false)
  811. _end:
  812. FunctionEnd
  813. Function un.isEmptyDir
  814. # Stack -> # Stack: <directory>
  815. Exch $0 # Stack: $0
  816. Push $1 # Stack: $1, $0
  817. FindFirst $0 $1 "$0\*.*"
  818. strcmp $1 "." 0 _notempty
  819. FindNext $0 $1
  820. strcmp $1 ".." 0 _notempty
  821. ClearErrors
  822. FindNext $0 $1
  823. IfErrors 0 _notempty
  824. FindClose $0
  825. Pop $1 # Stack: $0
  826. StrCpy $0 1
  827. Exch $0 # Stack: 1 (true)
  828. goto _end
  829. _notempty:
  830. FindClose $0
  831. ClearErrors
  832. Pop $1 # Stack: $0
  833. StrCpy $0 0
  834. Exch $0 # Stack: 0 (false)
  835. _end:
  836. FunctionEnd