ui_laser_setup.nsh 62 KB

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