123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785 |
-
- !include "StrFunc.nsh"
- !include "WordFunc.nsh"
- ${StrRep}
- ${StrStr}
- !include "LogicLib.nsh"
- !include "nsDialogs.nsh"
- !include "common.nsh"
- !include "x64.nsh"
- !include "MUI2.nsh"
- !include "WinVer.nsh"
- !include "commonfunc.nsh"
- VIProductVersion "${PRODUCT_VERSION}"
- VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
- VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
- VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
- VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
- VIAddVersionKey "InternalName" "${EXE_NAME}"
- VIAddVersionKey "FileDescription" "${PRODUCT_NAME}"
- VIAddVersionKey "LegalCopyright" "${PRODUCT_LEGAL}"
- !define INSTALL_PAGE_REG 0
- !define INSTALL_PAGE_CONFIG 1
- ;!define INSTALL_PAGE_LICENSE 1
- !define INSTALL_PAGE_PROCESSING 2
- !define INSTALL_PAGE_FINISH 3
- !define INSTALL_PAGE_UNISTCONFIG 4
- !define INSTALL_PAGE_UNISTPROCESSING 5
- !define INSTALL_PAGE_UNISTFINISH 6
- Page custom DUIPage
- UninstPage custom un.DUIPage
- Var hInstallDlg
- Var hInstallSubDlg
- Var sSetupPath
- Var sReserveData
- Var InstallState
- Var UnInstallValue
- Var basedir
- Var datadir
- Var logError
- Var buildModelPath
- Var profilePath
- Var buildCallPath
- Var dbpath
- Var logpath
- Var binPath
- Var javaPath
- Var temp12
- Var OLD_VER
- Var vc_flag
- Var machine
- Var regCode
- Var update
- !include "ui_laser_lang.nsi"
- Function SelectLanguage
- ;根据windowsapi返回值选择语言,不支持语言默认显示英文
- System::Call 'Kernel32::GetUserDefaultUILanguage() i.r0'
- ${If} $0 == '2052'
- StrCpy $LANGUAGE $0
- ${Else}
- StrCpy $LANGUAGE 1033
- ${EndIf}
- FunctionEnd
- ;在安装程序运行前的回调函数前实现
- Function .onInit
- Debug::Watcher
- Call SelectLanguage
- Call checkInstall
- Push ""
- Push ${LANG_ENGLISH} ;添加英文代码 语言代码是系统变量,多语言引入后,自动加载,拼接方式是“LANG_语言”,可以查看NSIS手册,LANG_ENGLISH的编号为1033,LANG_SIMPCHINESE为2052;
- Push "English"
- Push ${LANG_SIMPCHINESE} ;添加简体中文选项
- Push "简体中文"
- Push ${LANG_JAPANESE}
- Push "日本語"
- Push ${LANG_KOREAN}
- Push "한국어"
- Push A ; A means auto count languages for the auto count to work the first empty push (Push "") must remain
- ${If} $0 == '2052'
- LangDLL::LangDialog "安装程序语言" "请选择安装程序的语言" ;显示语言选择对话框
- ${ElseIf} $0 == '1033'
- LangDLL::LangDialog "Installer Language" "Please select the language of the installer" ;显示语言选择对话框
- ${ElseIf} $0 == '1041'
- LangDLL::LangDialog "インストーラ言語" "インストーラの言語を選択してください" ;显示语言选择对话框
- ${ElseIf} $0 == '1042'
- LangDLL::LangDialog "설치 프로그램 언어" "설치 프로그램의 언어를 선택하십시오" ;显示语言选择对话框
- ${Else}
- LangDLL::LangDialog "Installer Language" "Please select the language of the installer" ;显示语言选择对话框
- ${EndIf}
- Pop $LANGUAGE ;获得用户对于语言的选择结果 ‘$LANGUAGE’是多语言变量,在安装程序结束后,语言代码会存储在这个变量中,手动修改‘$LANGUAGE’的值后,安装包会重新选择最匹配的语言,参考最上面NSIS手册中选择界面语言步骤
- StrCmp $LANGUAGE "cancel" 0 +2
- Abort
- ${If} $LANGUAGE == '1033'
- Call startCheckEn
- ${ElseIf} $LANGUAGE == '1041'
- Call startCheckJp
- ${ElseIf} $LANGUAGE == '1042'
- Call startCheckKr
- ${ElseIf} $LANGUAGE == '2052'
- Call startCheck
- ${Else}
- Call startCheckEn
- ${EndIf}
- FunctionEnd
- Function checkInstall
- System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
- Pop $R0
- StrCmp $R0 0 SKIP RUN
- RUN:
- ${If} $LANGUAGE == '1033'
- MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
- Abort
- ${ElseIf} $LANGUAGE == '1041'
- MessageBox MB_OK|MB_USERICON "インストールが既に起動されています。重複起動を避けてください。"
- Abort
- ${ElseIf} $LANGUAGE == '1042'
- MessageBox MB_OK|MB_USERICON "설치 마법사가 이미 실행 중입니다. 반복적으로 켜지 마십시오."
- Abort
- ${ElseIf} $LANGUAGE == '2052'
- MessageBox MB_OK|MB_USERICON "有一个安装向导已经运行,请勿重复打开。"
- Abort
- ${Else}
- MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
- Abort
- ${EndIf}
- Goto END
- SKIP:
- Goto END
- END:
- FunctionEnd
- Function startCheck
- StrCpy $update "1"
- ${IfNot} ${AtLeastWin10}
- MessageBox MB_OK|MB_USERICON "本程序只能安装在windows-10(64位)系统及以上"
- Abort
- ${EndIf}
- SetRegView 64
- ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
- ${IF} $OLD_VER != ""
- ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
- ${If} $R0 == "0"
- MessageBox MB_OK|MB_USERICON '版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
- Quit
- ${EndIf}
- ${If} $R0 == "1"
- MessageBox MB_OK|MB_USERICON '版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
- Quit
- ${EndIf}
- ${If} $R0 == "2"
- MessageBox MB_OK|MB_USERICON '您安装的版本是 ${PRODUCT_VERSION} ,高于版本 $OLD_VER,可以执行更新操作 '
- StrCpy $update "0"
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function startCheckEn
- StrCpy $update "1"
- ${IfNot} ${AtLeastWin10}
- MessageBox MB_OK|MB_USERICON "This program can only be installed on Windows 10 (64-bit) and updated systems."
- Abort
- ${EndIf}
- SetRegView 64
- ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
- ${IF} $OLD_VER != ""
- ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
- ${If} $R0 == "0"
- MessageBox MB_OK|MB_USERICON 'Version $OLD_VER is installed on the computer. To reinstall,please uninstall the existing version first.'
- Quit
- ${EndIf}
- ${If} $R0 == "1"
- MessageBox MB_OK|MB_USERICON 'Version $OLD_VER is installed on the computer. To reinstall,please uninstall the existing version first.'
- Quit
- ${EndIf}
- ${If} $R0 == "2"
- 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'
- StrCpy $update "0"
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function startCheckKr
- StrCpy $update "1"
- ${IfNot} ${AtLeastWin10}
- MessageBox MB_OK|MB_USERICON "このプログラムは、 Windows-10(64ビット)システム以上にのみインストールできます。"
- Abort
- ${EndIf}
- SetRegView 64
- ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
- ${IF} $OLD_VER != ""
- ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
- ${If} $R0 == "0"
- MessageBox MB_OK|MB_USERICON '$OLD_VER 버전이 컴퓨터에 설치되어 있습니다.다시 설치하려면 먼저 기존 버전을 제거하십시오.'
- Quit
- ${EndIf}
- ${If} $R0 == "1"
- MessageBox MB_OK|MB_USERICON '$OLD_VER 버전이 컴퓨터에 설치되어 있습니다.다시 설치하려면 먼저 기존 버전을 제거하십시오.'
- Quit
- ${EndIf}
- ${If} $R0 == "2"
- MessageBox MB_OK|MB_USERICON '설치하는 버전은 $OLD_VER 버전보다 최신 버전인 ${PRODUCT_VERSION} 이며 업데이트된 작업을 수행할 수 있습니다. '
- StrCpy $update "0"
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function startCheckJp
- StrCpy $update "1"
- ${IfNot} ${AtLeastWin10}
- MessageBox MB_OK|MB_USERICON "이 프로그램은 Windows 10 (64 비트) 및 업데이트된 시스템에만 설치할 수 있습니다."
- Abort
- ${EndIf}
- SetRegView 64
- ReadRegStr $OLD_VER HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
- ${IF} $OLD_VER != ""
- ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
- ${If} $R0 == "0"
- MessageBox MB_OK|MB_USERICON 'バージョン $OLD_VER が既にインストールされていました。再インストールするには、既存のインストールをアンインストールしてください。'
- Quit
- ${EndIf}
- ${If} $R0 == "1"
- MessageBox MB_OK|MB_USERICON 'バージョン $OLD_VER が既にインストールされていました。再インストールするには、既存のインストールをアンインストールしてください。'
- Quit
- ${EndIf}
- ${If} $R0 == "2"
- MessageBox MB_OK|MB_USERICON '現在インストールのバージョン:${PRODUCT_VERSION}、バージョン $OLD_VER より新しいです。アップデートが可能です。 '
- StrCpy $update "0"
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function un.checkInstall
- SetRegView 64
- ReadRegStr $LANGUAGE HKLM "Software\${PRODUCT_PATHNAME}" "language"
- System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
- Pop $R0
- StrCmp $R0 0 SKIP RUN
- RUN:
- ${If} $LANGUAGE == '1033'
- MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
- Abort
- ${ElseIf} $LANGUAGE == '1041'
- MessageBox MB_OK|MB_USERICON "インストールが既に起動されています。重複起動を避けてください。"
- Abort
- ${ElseIf} $LANGUAGE == '1042'
- MessageBox MB_OK|MB_USERICON "설치 마법사가 이미 실행 중입니다. 반복적으로 켜지 마십시오."
- Abort
- ${ElseIf} $LANGUAGE == '2052'
- MessageBox MB_OK|MB_USERICON "有一个安装向导已经运行,请勿重复打开。"
- Abort
- ${Else}
- MessageBox MB_OK|MB_USERICON "An installation wizard is already running, please do not turn it on repeatedly."
- Abort
- ${EndIf}
- Goto END
- SKIP:
- Goto END
- END:
- FunctionEnd
- Function un.onInit
- Debug::Watcher
- SetRegView 64
- Call un.checkInstall
- FunctionEnd
- Function DUIPage
- StrCpy $InstallState "0"
- InitPluginsDir
- SetOutPath "$PLUGINSDIR"
- File "${INSTALL_LICENCE_FILENAME_ZH}"
- File "${INSTALL_LICENCE_FILENAME_EN}"
- File "${INSTALL_RES_PATH}"
- File /oname=logo.ico "${INSTALL_ICO}"
- File /oname=main.exe "${INSTALL_REG}"
- StrCmp $LANGUAGE 2052 ZH_INI EN_INI
- EN_INI:
- nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" "${INSTALL_LICENCE_FILENAME_EN}"
- Goto END
- ZH_INI:
- nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" "${INSTALL_LICENCE_FILENAME_ZH}"
- Goto END
- END:
- Pop $hInstallDlg
- ReadRegStr $regCode HKCR "Software\${PRODUCT_PATHNAME}" "regCode"
- ; MessageBox MB_OK "Exit code:$machine"
- Call initConfigPage
- Call BindUIControls
- ${IF} $regCode == ""
- ; MessageBox MB_OK "machine empty :$machine"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_REG}
- Call initRegPage
- Call onGetMachineinfo
- ${Else}
- nsExec::ExecToStack "$PLUGINSDIR\main.exe -m v -r $regCode "
- Pop $0
- ${If} $0 == 1
- ${If} $update == "1"
- ;新装
- ;生成安装路径,包含识别旧的安装路径
- Call GenerateSetupAddress
- #设置控件显示安装路径
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
- Call OnRichEditTextChange
- #nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnAgreement" "text" " 用户许可协议"
- ${Else}
- ;更新
- SetRegView 64
- ReadRegStr $0 HKLM "Software\${PRODUCT_PATHNAME}" "InstPath"
- ${If} "$0" != "" #路径不存在,则重新选择路径
- #路径读取到了,直接使用
- #再判断一下这个路径是否有效
- nsNiuniuSkin::StringHelper "$0" "\\" "\" "replace"
- Pop $0
- StrCpy $INSTDIR "$0"
- ${EndIf}
- #设置控件显示安装路径
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
- Call OnRichEditTextChange
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnSelectDir" "visible" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "text" $(ONE_CLICK_UPDATE)
- ${EndIf}
- ;设置安装包的标题及任务栏显示
- nsNiuniuSkin::SetWindowTile $hInstallDlg "$(PRODUCT_NAME_LANG)$(SETUP)"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licensename" "text" $(USER_LICENSE_AGREEMENT)
- ${Else}
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_REG}
- Call initRegPage
- call onGetMachineinfo
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_space" "text" $(KEY_DOES_NOT_MATCH)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_space" "textcolor" "#ffff0000"
- ${EndIf}
- ${EndIf}
- nsNiuniuSkin::ShowPage 0
- FunctionEnd
- Function un.DUIPage
- StrCpy $InstallState "0"
- InitPluginsDir
- SetOutPath "$PLUGINSDIR"
- File "${INSTALL_RES_PATH}"
- File /oname=logo.ico "${UNINSTALL_ICO}"
- nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" ""
- Pop $hInstallDlg
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTCONFIG}
- Call un.initUnInstallPage
- nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}$(UNINSTALL_SETUP)"
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390s
- Call un.BindUnInstUIControls
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAutoRun" "selected" "true"
- nsNiuniuSkin::ShowPage 0
- FunctionEnd
- Function OnCheckRegClick
- #可在此获取路径,判断是否合法等处理
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "reg_reg_info" "text"
- Pop $0
- StrCpy $temp12 "$0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_space" "text" ""
- ${If} $temp12 == ''
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_space" "text" $(KEY_DOES_NOT_NULL)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_space" "textcolor" "#ffff0000"
- ${Else}
- nsExec::ExecToStack "$PLUGINSDIR\main.exe -m v -r $temp12 "
- Pop $0
- ${If} $0 == 1
- #生成安装路径,包含识别旧的安装路径
- Call GenerateSetupAddress
- #设置控件显示安装路径
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
- Call OnRichEditTextChange
- #设置安装包的标题及任务栏显示
- nsNiuniuSkin::SetWindowTile $hInstallDlg "$(PRODUCT_NAME_LANG)$(SETUP)"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licensename" "text" $(USER_LICENSE_AGREEMENT)
- #nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnAgreement" "text" " 用户许可协议"
- ${If} $update == "1"
- #生成安装路径,包含识别旧的安装路径
- Call GenerateSetupAddress
- #设置控件显示安装路径
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
- Call OnRichEditTextChange
- ${Else}
- ;更新
- SetRegView 64
- ReadRegStr $0 HKLM "Software\${PRODUCT_PATHNAME}" "InstPath"
- ${If} "$0" != "" #路径不存在,则重新选择路径
- #路径读取到了,直接使用
- #再判断一下这个路径是否有效
- nsNiuniuSkin::StringHelper "$0" "\\" "\" "replace"
- Pop $0
- StrCpy $INSTDIR "$0"
- ${EndIf}
- #设置控件显示安装路径
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
- Call OnRichEditTextChange
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnSelectDir" "visible" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "text" $(ONE_CLICK_UPDATE)
- ${EndIf}
- ;设置安装包的标题及任务栏显示
- nsNiuniuSkin::SetWindowTile $hInstallDlg "$(PRODUCT_NAME_LANG)$(SETUP)"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licensename" "text" $(USER_LICENSE_AGREEMENT)
- Call BindUIControls
- nsNiuniuSkin::ShowPage 0
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_space" "text" $(KEY_DOES_NOT_MATCH)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_space" "textcolor" "#ffff0000"
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function onGetMachineinfo
- WriteRegStr HKLM "Software\${PRODUCT_PATHNAME}" "machine" ""
- nsExec::ExecToStack "$PLUGINSDIR\main.exe -m g "
- Pop $0
- ${If} $0 == 1
- ReadRegStr $machine HKLM "Software\${PRODUCT_PATHNAME}" "machine"
- ${IF} $machine != ""
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_machine_info" "text" "$machine"
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function onCopyMachineinfoClick
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "reg_machine_info" "text"
- Pop $0
- nsExec::ExecToStack '"cmd.exe" /c echo $0| clip'
- FunctionEnd
- Function un.BindUnInstUIControls
- GetFunctionAddress $0 un.ExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnUninstalled" $0
- GetFunctionAddress $0 un.onUninstall
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnUnInstall" $0
- GetFunctionAddress $0 un.ExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
- GetFunctionAddress $0 un.ExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnUnClose" $0
- GetFunctionAddress $0 un.OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
- GetFunctionAddress $0 un.BtnDirPre
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
- ; GetFunctionAddress $0 un.onNoPassUninstall
- ; nsNiuniuSkin::BindCallBack $hInstallDlg "backupBtnOK" $0
- ; GetFunctionAddress $0 un.onPassUninstall
- ; nsNiuniuSkin::BindCallBack $hInstallDlg "gotouninstall" $0
- GetFunctionAddress $0 un.OnbtnUninstalledReboot
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnUninstalledReboot" $0
- FunctionEnd
- Function BindUIControls
- # 注册页面
- GetFunctionAddress $0 onCopyMachineinfoClick
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnCopyMachineinfo" $0
- GetFunctionAddress $0 OnCheckRegClick
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnRegConfirm" $0
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseClose" $0
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseMin" $0
- GetFunctionAddress $0 OnBtnLicenseClick
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgreement" $0
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirClose" $0
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseCancel" $0
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirMin" $0
- GetFunctionAddress $0 OnBtnSelectDir
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnSelectDir" $0
- GetFunctionAddress $0 OnBtnDirPre
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
- GetFunctionAddress $0 OnBtnShowConfig
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgree" $0
- GetFunctionAddress $0 OnBtnCancel
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirCancel" $0
- GetFunctionAddress $0 OnBtnInstall
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnInstall" $0
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailClose" $0
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailMin" $0
- GetFunctionAddress $0 OnFinished
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnRun" $0
- GetFunctionAddress $0 OnBtnMin
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
- GetFunctionAddress $0 OnExitDUISetup
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
- GetFunctionAddress $0 OnCheckLicenseClick
- nsNiuniuSkin::BindCallBack $hInstallDlg "chkAgree" $0
- GetFunctionAddress $0 OnBtnShowMore
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnShowMore" $0
- GetFunctionAddress $0 OnBtnHideMore
- nsNiuniuSkin::BindCallBack $hInstallDlg "btnHideMore" $0
- GetFunctionAddress $0 OnSysCommandCloseEvent
- nsNiuniuSkin::BindCallBack $hInstallDlg "syscommandclose" $0
- GetFunctionAddress $0 OnRichEditTextChange
- nsNiuniuSkin::BindCallBack $hInstallDlg "editDir" $0
- FunctionEnd
- Function un.OnbtnUninstalledReboot
- ; MessageBox MB_OK "OnbtnUninstalledR:eboot--Reboot"
- Reboot
- FunctionEnd
- Function OnRichEditTextChange
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
- Pop $0
- StrCpy $INSTDIR "$0"
- Call onVerifyInstDir
- Pop $0
- ${If} $0 == 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_ZH_PATH)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto TextChangeAbort
- ${EndIf}
- ${If} $0 == 2
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_CANNOT_EMPTY)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto TextChangeAbort
- ${EndIf}
- Call onVerifySpecialInstDir
- ${If} $0 == 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_SPECIAL_CHARACTERS)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto TextChangeAbort
- ${EndIf}
- Call IsSetupPathIlleagal
- ${If} $R5 == "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_ERROR)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto TextChangeAbort
- ${EndIf}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#FF999999"
- ${If} $R0 > 1024
- IntOp $R1 $R0 % 1024
- IntOp $R0 $R0 / 1024;
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "$(REMAINING_SPACE):$R0.$R1GB"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "$(REMAINING_SPACE):$R0.$R1MB"
- ${endif}
- ${IF} ${CJ} == "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
- ${Else}
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
- Pop $0
- ${If} $0 == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- ${EndIf}
- ${EndIf}
- TextChangeAbort:
- FunctionEnd
- Function OnCheckLicenseClick
- ${IF} ${CJ} == "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
- ${Else}
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
- Pop $0
- ${If} $0 == "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- ${EndIf}
- ${EndIf}
- FunctionEnd
- Function OnBtnLicenseClick
- ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_LICENSE}
- Call initLicensePage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "true"
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "moreconfiginfo" "visible"
- Pop $0
- ${If} $0 = 0
- ;pos="10,35,560,405"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,385"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "270"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,495"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "375"
- ${EndIf}
- FunctionEnd
- Section "silentInstallSec" SEC01
- #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent install code here."
- SectionEnd
- Function ShowMsgBox
- nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
- Pop $hInstallSubDlg
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "btnOK" "text" $(BTN_CONFIRM)
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "btnCancel" "text" $(BTN_CANCEL)
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" $(PROMPT)
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
- ${If} "$R7" == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
- ${EndIf}
- nsNiuniuSkin::ShowSkinSubPage 0
- FunctionEnd
- Function OnBtnInstall
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
- Pop $0
- StrCpy $INSTDIR "$0"
- Call onVerifyInstDir
- Pop $0
- ${If} $0 == 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_ZH_PATH)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto InstallAbort
- ${EndIf}
- ${If} $0 == 2
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_CANNOT_EMPTY)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto InstallAbort
- ${EndIf}
- Call onVerifySpecialInstDir
- ${If} $0 == 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(CANNOT_CONTAIN_SPECIAL_CHARACTERS)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto InstallAbort
- ${EndIf}
- Call IsSetupPathIlleagal
- ${If} $R5 == "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" $(PATH_ERROR)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
- goto InstallAbort
- ${EndIf}
- ; MessageBox MB_OK|MB_USERICON '$INSTDIR\install.flag'
- ${If} ${FileExists} "$INSTDIR\install.flag"
- SetRebootFlag true
- MessageBox MB_OK $(REBOOT_PROMPT)
- Quit
- ${EndIf}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#FF999999"
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
- Pop $0
- StrCpy $0 "1"
- StrCmp $0 "0" InstallAbort 0
- nsProcess::_FindProcess "${EXE_NAME_EXT}"
- Pop $R0
- ${If} $R0 == 0
- StrCpy $R8 "${PRODUCT_NAME} $(TO_RUNNING)"
- StrCpy $R7 "0"
- Call ShowMsgBox
- goto InstallAbort
- ${EndIf}
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
- Pop $0
- StrCmp $0 "" InstallAbort 0
- Call AdjustInstallPath
- StrCpy $sSetupPath "$INSTDIR"
- Call IsSetupPathIlleagal
- ${If} $R5 == "0"
- StrCpy $R8 $(PATH_ERROR_TWO)
- StrCpy $R7 "0"
- Call ShowMsgBox
- goto InstallAbort
- ${EndIf}
- ${If} $R5 == "-1"
- StrCpy $R8 $(DISK_SPACE_ERROR)
- StrCpy $R7 "0"
- Call ShowMsgBox
- goto InstallAbort
- ${EndIf}
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
- Call initInstallingPage
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_PROCESSING}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "min" "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "max" "100"
- #Call BakFiles
- ${If} $update == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INSTALLING)
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(STOPPING_SERVICE)
- SimpleSC::StopService "lasermongodb" 0 30
- SimpleSC::StopService "lasermysql" 0 30
- SimpleSC::StopService "laserredis" 0 30
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(REMOVE_FILES)
- RMDir /r "$INSTDIR\bin"
- BgWorker::CallAndWait
- RMDir /r "$INSTDIR\CGAII"
- Sleep 2000
- BgWorker::CallAndWait
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(UPDATING)
- ${EndIf}
- GetFunctionAddress $0 ExtractFunc
- BgWorker::CallAndWait
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkShotcut" "selected"
- #Pop $R0
- # ${If} $R0 == "1"
- # SetShellVarContext all
- # CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
- # SetShellVarContext current
- # ${EndIf}
- SetOutPath "$INSTDIR\bin"
- SetShellVarContext all
- Delete "$DESKTOP\四维看看本地版.lnk"
- Delete "$DESKTOP\4DKanKan.lnk"
- CreateShortCut "$DESKTOP\$(PRODUCT_NAME_LANG).lnk" "$INSTDIR\${EXE_NAME}"
- SetShellVarContext current
- Call CreateAppShortcut
- Call CreateUninstall
- ${If} $update == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INITIALIZING)
- GetFunctionAddress $0 OnEnvInstall
- BgWorker::CallAndWait
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INITIALIZING_SERVICE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" $(INITIALIZING_SERVICE)
- GetFunctionAddress $0 installService
- BgWorker::CallAndWait
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(INITIALIZING_SERVICE_DONE)
- ${Else}
- SimpleSC::StartService "lasermongodb" "" 30
- SimpleSC::StartService "lasermysql" "" 30
- SimpleSC::StartService "laserredis" "" 30
- Sleep 2000
- ;
- ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_DATA\' '\' '\\'
- StrCpy $buildModelPath $0
- ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_STATIC\' '\' '\\'
- StrCpy $profilePath $0
- ${StrRep} $0 '$INSTDIR\CGAII' '\' '\\'
- StrCpy $buildCallPath $0
- ${StrRep} $0 '$INSTDIR\bin\resources\static' '\' '\\'
- StrCpy $binPath $0
- ${StrRep} $0 '$INSTDIR\jdk1.8\bin\java.exe' '\' '\\'
- StrCpy $javaPath $0
- nsJSON::Set /file $INSTDIR\bin\resources\static\setting.json
- nsJSON::Set /value `{}`
- nsJSON::Set `sceneConfig` /value `"config.json"`
- nsJSON::Set `sceheKey` /value `"id"`
- nsJSON::Set `sceneBundle` /value `"./build.zip"`
- nsJSON::Set `sceneBundleDir` /value `"capture"`
- nsJSON::Set `buildModelPath` /value `"$buildModelPath"`
- nsJSON::Set `javaPort` /value `9000`
- nsJSON::Set `v4JavaPort` /value `9101`
- nsJSON::Set `javaPath` /value `"$javaPath"`
- nsJSON::Set `profilePath` /value `"$profilePath"`
- nsJSON::Set `buildCallPath` /value `"$buildCallPath"`
- nsJSON::Set `binPath` /value `"$binPath"`
- nsJSON::Set `fuse` /value `${FUSE}`
- nsJSON::Set `ver` /value `${VER}`
- nsJSON::Set `version` /value `"${VERSION}"`
- nsJSON::Serialize /format /file $INSTDIR\bin\resources\static\setting.json
- nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m u -i $INSTDIR"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" $(UPDATING_DONE)
- ${EndIf}
- StrCpy $InstallState "1"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_FINISH}
- Call initFinishPage
- #Call OnFinished
- ${If} $update == "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnRun" "text" $(UPDATING_DONE)
- ${EndIf}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
- ;完成安装删除计划任务
- nsExec::ExecToStack 'schtasks /delete /tn "DeleteInstallFlagTask" /f'
- InstallAbort:
- FunctionEnd
- Function ExtractCallback
- Pop $1
- Pop $2
- System::Int64Op $1 * 100
- Pop $3
- System::Int64Op $3 / $2
- Pop $0
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "$0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "$0%"
- ${If} $1 == $2
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "100"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "100%"
- ${EndIf}
- FunctionEnd
- Function OnSysCommandCloseEvent
- Call OnExitDUISetup
- FunctionEnd
- Function OnExitDUISetup
- ${If} $InstallState == "0"
- StrCpy $R8 "$(CONFIRM_EXIT)"
- StrCpy $R7 "1"
- Call ShowMsgBox
- pop $0
- ${If} $0 == 0
- goto endfun
- ${EndIf}
- ${EndIf}
- nsNiuniuSkin::ExitDUISetup
- endfun:
- FunctionEnd
- Function OnBtnMin
- SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
- FunctionEnd
- Function OnBtnCancel
- nsNiuniuSkin::ExitDUISetup
- FunctionEnd
- Function OnEnvInstall
- EnVar::SetHKLM
- EnVar::AddValue FDMGEA_HOME "$INSTDIR"
- ;EnVar::SetHKLM
- ;EnVar::AddValue JAVA_HOME "$INSTDIR\jdk1.8"
- EnVar::SetHKLM
- EnVar::AddValue MYSQL_HOME "$INSTDIR\mysql"
- EnVar::SetHKLM
- EnVar::AddValue REDIS_HOME "$INSTDIR\redis"
- EnVar::SetHKLM
- EnVar::AddValue 4DKK_HOME "$INSTDIR\CGAII;$INSTDIR\CGAII\3dtile"
- EnVar::SetHKLM
- EnVar::AddValue MONGODB_HOME "$INSTDIR\mongodb"
- ;EnVar::SetHKLM
- ;EnVar::AddValue CLASS_PATH ".;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
- EnVar::SetHKLM
- ;EnVar::AddValue "Path" "$INSTDIR\jdk1.8\bin;$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;"
- EnVar::AddValue "Path" "$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;$INSTDIR\CGAII\3dtile"
- SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
- ;nsExec::ExecToStack '"$INSTDIR\tools\env_install.bat" $INSTDIR '
- FunctionEnd
- Function un.OnEnvDownInstall
- EnVar::SetHKLM
- EnVar::Delete "FDMGEA_HOME" "$INSTDIR"
- ;EnVar::Delete "JAVA_HOME" "$INSTDIR\jdk1.8"
- EnVar::Delete "MYSQL_HOME" "$INSTDIR\mysql"
- EnVar::Delete "REDIS_HOME" "$INSTDIR\redis"
- EnVar::Delete "4DKK_HOME" "$INSTDIR\CGAII"
- EnVar::Delete "4DKK_HOME" "$INSTDIR\CGAII\3dtile"
- EnVar::Delete "MONGODB_HOME" "$INSTDIR\mongodb"
- ;EnVar::Delete "CLASS_PATH" "%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
- ;EnVar::DeleteValue "PATH" "%JAVA_HOME%\bin"
- EnVar::DeleteValue "PATH" "$INSTDIR\mysql\bin"
- EnVar::DeleteValue "PATH" "$INSTDIR\mongodb\bin"
- EnVar::DeleteValue "PATH" "$INSTDIR\redis"
- EnVar::DeleteValue "PATH" "$INSTDIR\CGAII"
- EnVar::DeleteValue "PATH" "$INSTDIR\CGAII\lib"
- EnVar::DeleteValue "PATH" "$INSTDIR\CGAII\3dtile"
- ;nsExec::ExecToStack '"$INSTDIR\tools\uninstall.bat" $INSTDIR '
- FunctionEnd
- Function un.installService
- nsExec::ExecToStack '"$INSTDIR\tools\unservice.bat"'
- SimpleSC::ExistsService "lasermongodb"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "lasermongodb" 0 30
- SimpleSC::RemoveService "lasermongodb"
- ${EndIf}
- SimpleSC::ExistsService "lasermysql"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "lasermysql" 0 30
- SimpleSC::RemoveService "lasermysql"
- ${EndIf}
- SimpleSC::ExistsService "laserredis"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "laserredis" 0 30
- SimpleSC::RemoveService "laserredis"
- ${EndIf}
- SimpleSC::ExistsService "checkLaserProcess"
- Pop $0
- ${If} $0 == 0
- SimpleSC::StopService "checkLaserProcess" 0 30
- SimpleSC::RemoveService "checkLaserProcess"
- ${EndIf}
- FunctionEnd
- Function installService
- ${StrRep} $0 '$INSTDIR\mysql' '\' '\\'
- StrCpy $basedir $0
- ${StrRep} $0 '$INSTDIR\mysql\data' '\' '\\'
- StrCpy $datadir $0
- ${StrRep} $0 '$INSTDIR\mysql\logs.log' '\' '\\'
- StrCpy $logError $0
- WriteINIStr $INSTDIR\mysql\my.ini mysqld port 3307
- WriteINIStr $INSTDIR\mysql\my.ini mysqld basedir $basedir
- WriteINIStr $INSTDIR\mysql\my.ini mysqld datadir $datadir
- WriteINIStr $INSTDIR\mysql\my.ini mysqld log-error $logError
- WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connections 1000
- WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connect_errors 10
- WriteINIStr $INSTDIR\mysql\my.ini mysqld character-set-server utf8mb4
- WriteINIStr $INSTDIR\mysql\my.ini mysqld default-storage-engine INNODB
- WriteINIStr $INSTDIR\mysql\my.ini mysqld default_authentication_plugin mysql_native_password
- WriteINIStr $INSTDIR\mysql\my.ini mysqld local_infile ON
- WriteINIStr $INSTDIR\mysql\my.ini mysql default-character-set utf8mb4
- WriteINIStr $INSTDIR\mysql\my.ini mysql local_infile ON
- WriteINIStr $INSTDIR\mysql\my.ini client port 3307
- WriteINIStr $INSTDIR\mysql\my.ini client default-character-set utf8mb4
- Sleep 2000
- SetOutPath "$INSTDIR\mysql\bin"
- ReadRegStr $vc_flag HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" "Installed"
- ${IF} $vc_flag != "1"
- nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\VC_redist.x64.exe /install /quiet /norestart'
- ${EndIf}
- Sleep 2000
- nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --initialize-insecure --lower-case-table-names=1'
- Sleep 2000
- nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
- ; Pop $0
- ; Pop $1
- ; ${If} $0 = 0
- ; nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
- ; ${Else}
- ; ;MessageBox mb_ok "code=$0,mes=$1"
- ; Sleep 2000
- ; nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --initialize-insecure --lower-case-table-names=1'
- ; Sleep 2000
- ; nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\mysql\bin\mysqld.exe --install lasermysql'
- ; ${EndIf}
- IfFileExists "$INSTDIR\USER_DATA\data\*.*" 0 static_not_found
- CopyFiles /SILENT $INSTDIR\USER_DATA\data\*.* $INSTDIR\mysql\data
- RMDir /r "$INSTDIR\USER_DATA\data\"
- Delete "$INSTDIR\mysql\sqlfile\fdkk_laser.sql"
- goto static_end_of
- static_not_found:
- goto static_end_of
- static_end_of:
- nsExec::ExecToStack '"cmd.exe" /c powercfg.exe /hibernate off '
- SimpleSC::StartService "lasermysql" "" 30
- SetOutPath "$INSTDIR\redis"
- nsExec::ExecToStack '"cmd.exe" /c redis-server.exe --service-install "$INSTDIR\redis\redis.windows.conf" --service-name laserredis --loglevel verbose'
- SimpleSC::StartService "laserredis" "" 30
- nsExec::ExecToStack '"cmd.exe" /c sc config laserredis start=auto'
- SimpleSC::RestartService "laserredis" "" 30
- Sleep 2000
- SetOutPath "$INSTDIR\mongodb"
- ${StrRep} $0 '$INSTDIR\mongodb\db' '\' '\\'
- StrCpy $dbpath $0
- ${StrRep} $0 '$INSTDIR\mongodb\logs\mongo.log' '\' '\\'
- StrCpy $logpath $0
- ClearErrors
- FileOpen $0 $INSTDIR\mongodb\mongo.conf w
- IfErrors otherW
- FileWrite $0 'port=29031$\n'
- FileWrite $0 'dbpath=$dbpath$\n'
- FileWrite $0 'logpath=$logpath$\n'
- FileWrite $0 'logappend=true$\n'
- FileWrite $0 'maxConns=1000$\n'
- FileClose $0
- goto done
- otherW:
- nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m w -i $INSTDIR\mongodb"
- goto done
- done:
- nsExec::ExecToStack '"cmd.exe" /c sc create lasermongodb binpath= "$INSTDIR\mongodb\bin\mongod.exe --config $INSTDIR\mongodb\mongo.conf --service" start= auto'
- SimpleSC::StartService "lasermongodb" "" 30
- Sleep 2000
- ; IfFileExists "$INSTDIR\USER_DATA\pro\*.*" 0 pro_not_found
- ; CopyFiles /SILENT $INSTDIR\USER_DATA\pro\*.* $INSTDIR\4DKK_PROGRAM_DATA
- ; RMDir /r "$INSTDIR\USER_DATA\pro"
- ; goto pro_end_of
- ; pro_not_found:
- ; goto pro_end_of
- ; pro_end_of:
- Sleep 2000
- ;
- ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_DATA\' '\' '\\'
- StrCpy $buildModelPath $0
- ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_STATIC\' '\' '\\'
- StrCpy $profilePath $0
- ${StrRep} $0 '$INSTDIR\CGAII' '\' '\\'
- StrCpy $buildCallPath $0
- ${StrRep} $0 '$INSTDIR\bin\resources\static' '\' '\\'
- StrCpy $binPath $0
- ${StrRep} $0 '$INSTDIR\jdk1.8\bin\java.exe' '\' '\\'
- StrCpy $javaPath $0
- nsJSON::Set /file $INSTDIR\bin\resources\static\setting.json
- nsJSON::Set /value `{}`
- nsJSON::Set `sceneConfig` /value `"config.json"`
- nsJSON::Set `sceheKey` /value `"id"`
- nsJSON::Set `sceneBundle` /value `"./build.zip"`
- nsJSON::Set `sceneBundleDir` /value `"capture"`
- nsJSON::Set `buildModelPath` /value `"$buildModelPath"`
- nsJSON::Set `javaPort` /value `9000`
- nsJSON::Set `v4JavaPort` /value `9101`
- nsJSON::Set `javaPath` /value `"$javaPath"`
- nsJSON::Set `profilePath` /value `"$profilePath"`
- nsJSON::Set `buildCallPath` /value `"$buildCallPath"`
- nsJSON::Set `binPath` /value `"$binPath"`
- nsJSON::Set `fuse` /value `${FUSE}`
- nsJSON::Set `ver` /value `${VER}`
- nsJSON::Set `version` /value `"${VERSION}"`
- nsJSON::Serialize /format /file $INSTDIR\bin\resources\static\setting.json
- nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m l -i $INSTDIR"
- ; FileOpen $0 $INSTDIR\bin\resources\static\4dmega.vmoptions w
- ; IfErrors done
- ; FileWrite $0 '-DBIN_PATH=$INSTDIR\bin\resources\static$\n'
- ; FileWrite $0 '-DPROFILE_PATH=$INSTDIR\4DKK_PROGRAM_STATIC\$\n'
- ; FileWrite $0 '-DBUILD_MODEL_PATH=$INSTDIR\4DKK_PROGRAM_DATA\$\n'
- ; FileWrite $0 '-DBUILD_CALL_PATH=$INSTDIR\CGAII\$\n'
- ; FileWrite $0 '-Dspring.profiles.active=standAloneProd$\n'
- ; FileWrite $0 '-Dserver.port=9000$\n'
- ; FileClose $0
- ; done:
- nsExec::ExecToStack '"cmd.exe" /c $INSTDIR\tools\MonitorPid.exe install '
- functionend
- Function OnFinished
- #MessageBox MB_YESNO|MB_ICONQUESTION "$(INSTALL_REBOOT)" IDNO +2
- #Reboot
- #Exec "$INSTDIR${EXE_NAME}"
- nsExec::ExecToStack 'ie4uinit.exe -ClearIconCache'
- nsExec::ExecToStack 'ie4uinit.exe -show'
- System::Call 'shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)'
- WriteRegStr HKLM "Software\${PRODUCT_PATHNAME}" "language" $LANGUAGE
- Call OnExitDUISetup
- FunctionEnd
- Function OnBtnSelectDir
- nsNiuniuSkin::SelectInstallDirEx $hInstallDlg $(PLEASE_SELECT_INSTALLATION_PATH)
- Pop $0
- ${Unless} "$0" == ""
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" $0
- ${EndUnless}
- FunctionEnd
- Function StepHeightSizeAsc
- ${ForEach} $R0 390 500 + 10
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
- Sleep 5
- ${Next}
- FunctionEnd
- Function StepHeightSizeDsc
- ${ForEach} $R0 480 390 - 10
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
- Sleep 5
- ${Next}
- FunctionEnd
- Function OnBtnShowMore
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "false"
- GetFunctionAddress $0 StepHeightSizeAsc
- BgWorker::CallAndWait
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 500
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
- FunctionEnd
- Function OnBtnHideMore
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "false"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "true"
- GetFunctionAddress $0 StepHeightSizeDsc
- BgWorker::CallAndWait
- nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
- FunctionEnd
- Function OnBtnShowConfig
- ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "false"
- FunctionEnd
- Function OnBtnDirPre
- StrCpy $R8 "$(CONFIRM_EXIT)"
- StrCpy $R7 "0"
- Call ShowMsgBox
- ;nsNiuniuSkin::PrePage "wizardTab"
- FunctionEnd
- Function un.BtnDirPre
- StrCpy $R8 "$(UNINSTALL)"
- StrCpy $R7 "0"
- Call un.ShowMsgBox
- ;nsNiuniuSkin::PrePage "wizardTab"
- FunctionEnd
- Function un.ShowMsgBoxBackUps
- nsNiuniuSkin::InitSkinSubPage "msgBox_backup.xml" "backupBtnOK" "gotouninstall"
- Pop $hInstallSubDlg
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" $(UNINSTALL_ERROR)
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "backupBtnOK" "text" $(I_KNOW)
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" $(PROMPT)
- nsNiuniuSkin::ShowSkinSubPage 0
- FunctionEnd
- Function un.ShowMsgBox
- nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
- Pop $hInstallSubDlg
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" $(PROMPT)
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
- ${If} "$R7" == "1"
- nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
- ${EndIf}
- nsNiuniuSkin::ShowSkinSubPage 0
- FunctionEnd
- Function un.ExitDUISetup
- nsExec::ExecToStack 'ie4uinit.exe -ClearIconCache'
- nsExec::ExecToStack 'ie4uinit.exe -show'
- System::Call 'shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)'
- nsNiuniuSkin::ExitDUISetup
- FunctionEnd
- Function un.OnBtnMin
- SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
- FunctionEnd
- Section "un.silentInstallSec" SEC02
- #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent uninstall code here."
- SectionEnd
- Function un.onUninstall
- nsProcess::_FindProcess "${EXE_NAME_EXT}"
- Pop $R0
- ${If} $R0 == 0
- StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
- StrCpy $R7 "0"
- Call un.ShowMsgBox
- goto InstallAbort
- ${EndIf}
- nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkbox_userdata" "selected"
- Pop $0
- StrCpy $sReserveData $0
- ${If} $sReserveData == 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" $(PREPARING_TO_UNINSTALL)
- CreateDirectory $INSTDIR\USER_DATA
- nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m v -i $INSTDIR"
- Pop $0
- ${If} $0 == 1
- Call un.onPassUninstall
- ${Else}
- RMDir /r "$INSTDIR\USER_DATA"
- Call un.ShowMsgBoxBackUps
- Pop $0
- ${If} $0 == 0
- Call un.onPassUninstall
- ${EndIf}
- ${If} $0 == 1
- Call un.onNoPassUninstall
- ${EndIf}
- ${EndIf}
- ${Else}
- Call un.onPassUninstall
- ${EndIf}
- InstallAbort:
- FunctionEnd
- Function un.onNoPassUninstall
- nsNiuniuSkin::ExitDUISetup
- FunctionEnd
- Function un.onPassUninstall
- ${If} $sReserveData == 1
- CreateDirectory $INSTDIR\USER_DATA
- ${EndIf}
- Call un.initUninstallingPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTPROCESSING}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "min" "0"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "max" "100"
- IntOp $UnInstallValue 0 + 1
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" $(PREPARING_TO_UNINSTALL)
- nsExec::ExecToStack "$INSTDIR\tools\laserOtherTools.exe -m b -i $INSTDIR "
- BgWorker::CallAndWait
- GetFunctionAddress $0 un.OnEnvDownInstall
- BgWorker::CallAndWait
- nsExec::ExecToStack 'cmd.exe /c powercfg.exe /hibernate on '
- GetFunctionAddress $0 un.installService
- BgWorker::CallAndWait
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" $(UNINSTALLING)
- Call un.DeleteShotcutAndInstallInfo
- IntOp $UnInstallValue $UnInstallValue + 8
- GetFunctionAddress $0 un.RemoveFiles
- BgWorker::CallAndWait
- FunctionEnd
- Function un.RemoveFiles
- ${Locate} "$INSTDIR" "/G=0 /M=*.*" "un.onDeleteFileFound"
- StrCpy $InstallState "1"
- ; 卸载成功后创建标记文件
- FileOpen $0 "$INSTDIR\install.flag" w
- FileClose $0
- ; 重启计算机
- ; 创建任务计划程序命令
- nsExec::ExecToStack 'schtasks /create /tn "DeleteInstallFlagTask" /tr "cmd.exe /C del $INSTDIR\install.flag" /sc onstart /ru System /rl HIGHEST /F'
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
- Call un.initUninstallFinishPage
- nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTFINISH}
- FunctionEnd
- Function un.onDeleteFileFound
- ; $R9 "path\name"
- ; $R8 "path"
- ; $R7 "name"
- ; $R6 "size" ($R6 = "" if directory, $R6 = "0" if file with /S=)
- ; MessageBox MB_OK "R9--------$R9"
- ; MessageBox MB_OK "R8--------$R8"
- ; MessageBox MB_OK "R7--------$R7"
- ;不用保留场景
- ${If} $sReserveData == 0
- ${If} $R7 != "install.flag"
- Delete "$R9"
- RMDir /r "$R9"
- RMDir "$R9"
- ${EndIf}
- ${EndIf}
- ;保留场景
- ${If} $sReserveData == 1
- ${If} $R7 != "install.flag"
- RMDir /r "$R8\bin"
- RMDir /r "$R8\CGAII"
- RMDir /r "$R8\mongodb"
- RMDir /r "$R8\mysql"
- RMDir /r "$R8\redis"
- RMDir /r "$R8\jdk1.8"
- ; RMDir /r "$R8\4DKK_PROGRAM_STATIC"
- ; RMDir /r "$R8\4DKK_PROGRAM_DATA"
- RMDir /r "$R8\tools"
- Delete "$R8\uninst.exe"
- ${EndIf}
- ${EndIf}
- IntOp $UnInstallValue $UnInstallValue + 2
- ${If} $UnInstallValue > 100
- IntOp $UnInstallValue 100 + 0
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
- ${Else}
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "$UnInstallValue"
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_pos" "text" "$UnInstallValue%"
- #Sleep 100
- ${EndIf}
- undelete:
- Push "LocateNext"
- FunctionEnd
- #
- # 以 Unicode 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
- # 但建议 Unicode 版本优先使用此函数。
- #
- Function PathIsDBCS_W
- Exch $R0
- Push $R1
- Push $R2
- Push $R3
- System::Call "*(&w${NSIS_MAX_STRLEN}R0)p.R1"
- StrCpy $R0 0
- StrCpy $R2 $R1
- lbl_loop:
- # Unicode 版取 2 个字节长度的字符,字符串遇到 0 字符表示结束了。
- System::Call "*$R2(&i2.R3)"
- IntCmp $R3 0 lbl_done
- # Unicode 字符直接判断字符值,大于 128 的我们就视为非英文字符。
- IntCmp $R3 128 0 lbl_skip
- IntOp $R0 $R0 !
- Goto lbl_done
- lbl_skip:
- # 如果用 NSIS 3.x 这里可以用 IntPtrOp 代替。
- IntOp $R2 $R2 + 2
- Goto lbl_loop
- lbl_done:
- System::Free $R1
- Pop $R3
- Pop $R2
- Pop $R1
- Exch $R0
- FunctionEnd
- #
- # 以 ANSI 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
- # 但建议 ANSI 版本优先使用此函数。
- #
- Function PathIsDBCS_A
- Exch $R0
- Push $R1
- Push $R2
- Push $R3
- Push $R4
- System::Call "*(&m${NSIS_MAX_STRLEN}R0)p.R1"
- StrCpy $R0 0
- StrCpy $R2 $R1
- lbl_loop:
- # ANSI 版取 1 个字节长度的字符,字符串遇到 0 字符表示结束了。
- System::Call "*$R2(&i1.R3)"
- IntCmp $R3 0 lbl_done
- # ANSI 字符用 IsDBCSLeadByte 判断是否双字节字符的前导字节。
- System::Call "kernel32::IsDBCSLeadByte(iR3)i.R4"
- IntCmp $R4 0 lbl_skip
- IntOp $R0 $R0 !
- Goto lbl_done
- lbl_skip:
- # 用 CharNextA 得到下一个字符的地址 (可正确处理双字节字符)。
- System::Call "user32::CharNextA(pR2)p.R2"
- Goto lbl_loop
- lbl_done:
- Pop $R4
- Pop $R3
- Pop $R2
- Pop $R1
- Exch $R0
- FunctionEnd
- #
- # 当选择的安装路径变更时,路径为空或包含双字节字符 (不限于简体中文),都不允许继续。
- # 路径为空时,NSIS 会自行判断。
- #
- # 此示例未判断是否包含空格。如有需要,请与示例一配合使用。
- #
- Function onVerifyInstDir
- # 检查安装路径是否包含双字节字符 (不限于简体中文)。
- StrCpy $0 $INSTDIR
- StrLen $1 $0
- # 这里也可以换成 CheckEnglishPath 以测试效果。
- ${If} $1 == 0
- Push 2
- ${Else}
- Push $INSTDIR
- Call PathIsDBCS_A
- Pop $R0
- Push $R0
- ${endif}
- lbl_done:
- FunctionEnd
- Function CheckEnglishPath
- Exch $0 ; 保存返回值的变量
- Exch ; 将字符串参数放在栈顶
- Push $1
- Push $2
- Push $3
- StrLen $1 $0 ; 计算字符串长度
- loop:
- StrCpy $2 $1 ; 复制当前长度
- IntOp $1 $1 - 1 ; 长度减1
- StrCpy $3 $0 1 $2 ; 获取当前字符
- ${If} $3 == " " ; 如果字符是空格
- Goto notEnglish ; 跳转到不是英文路径的逻辑
- ${EndIf}
- ${If} $1 > 0 ; 如果还有字符未检查
- Goto loop ; 继续循环
- ${EndIf}
- ; 路径是全英文的
- Pop $3
- Pop $2
- Pop $1
- StrCpy $0 0
- Exch $0
- notEnglish:
- ; 路径不是全英文的
- Pop $3
- Pop $2
- Pop $1
- StrCpy $0 1
- Exch $0
- FunctionEnd
- Function onVerifySpecialInstDir
- # 检查安装路径是否包含双字节字符 (不限于简体中文)。
- StrCpy $0 $INSTDIR
- StrLen $1 $0
- # 这里也可以换成 PathIsDBCS_A 以测试效果。
- ${If} $1 == 0
- Push 2
- ${Else}
- Push $INSTDIR
- Call CheckSpecialCharacters
- Pop $0 ; 获取返回结果
- Push $R0
- ${endif}
- FunctionEnd
- Function CheckSpecialCharacters
- Exch $0 ; 保存返回值的变量
- Exch ; 将字符串参数放在栈顶
- StrCpy $1 "!@#¥%……&*()!@#$%^&*()<>_+{}[];'?.,~`" ; 特殊字符
- StrCpy $2 0 ; 特殊字符字符串索引
- StrCpy $3 0 ; 字符串索引
- StrLen $4 $0 ; 特殊字符字符串长度
- loop:
- StrCpy $5 $1 1 $2 ; 从特殊字符字符串中获取一个字符
- StrCpy $6 $0 1 $3 ; 从需要检查的字符串中获取一个字符
- StrCmp $5 "" done ; 如果特殊字符字符串已经检查完,跳转到 done
- StrCmp $6 "" next ; 如果需要检查的字符串已经检查完,跳转到 next
- StrCmp $5 $6 found ; 如果找到特殊字符,跳转到 found
- IntOp $3 $3 + 1 ; 否则,增加需要检查的字符串的索引
- Goto loop
- next:
- IntOp $2 $2 + 1 ; 增加特殊字符字符串的索引
- StrCpy $3 0 ; 重置需要检查的字符串的索引
- Goto loop
- found:
- StrCpy $0 "1"
- Goto End
- done:
- StrCpy $0 "0"
- end:
- Exch $0 ; 将返回值出栈
- FunctionEnd
- Function isEmptyDir
- # Stack -> # Stack: <directory>
- Exch $0 # Stack: $0
- Push $1 # Stack: $1, $0
- FindFirst $0 $1 "$0\*.*"
- strcmp $1 "." 0 _notempty
- FindNext $0 $1
- strcmp $1 ".." 0 _notempty
- ClearErrors
- FindNext $0 $1
- IfErrors 0 _notempty
- FindClose $0
- Pop $1 # Stack: $0
- StrCpy $0 1
- Exch $0 # Stack: 1 (true)
- goto _end
- _notempty:
- FindClose $0
- ClearErrors
- Pop $1 # Stack: $0
- StrCpy $0 0
- Exch $0 # Stack: 0 (false)
- _end:
- FunctionEnd
- Function un.isEmptyDir
- # Stack -> # Stack: <directory>
- Exch $0 # Stack: $0
- Push $1 # Stack: $1, $0
- FindFirst $0 $1 "$0\*.*"
- strcmp $1 "." 0 _notempty
- FindNext $0 $1
- strcmp $1 ".." 0 _notempty
- ClearErrors
- FindNext $0 $1
- IfErrors 0 _notempty
- FindClose $0
- Pop $1 # Stack: $0
- StrCpy $0 1
- Exch $0 # Stack: 1 (true)
- goto _end
- _notempty:
- FindClose $0
- ClearErrors
- Pop $1 # Stack: $0
- StrCpy $0 0
- Exch $0 # Stack: 0 (false)
- _end:
- FunctionEnd
- Function initRegPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_title" "bkimage" $(REG_TITLE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "install_info" "text" $(INSTALL_INFO)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "machineCode" "text" $(MACHINE_CODE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "reg_machine_info" "text" $(REG_MACHINE_INFO)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnCopyMachineinfo" "text" $(BTN_COPY_MACHINEINFO)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "installKey" "text" $(INSTALL_KEY)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "regPrompt" "text" $(REG_PROMPT)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnRegConfirm" "text" $(BTN_REG_CONFIRM)
- FunctionEnd
- Function initConfigPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "configPageTitle" "bkimage" $(CONFIG_PAGE_TITLE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "configInstallPath" "text" $(CONFIG_INSTALL_PATH)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "configUseSpace" "text" $(CONFIG_USE_SPACE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAgree" "text" $(CONFIG_CHK_AGREE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnAgreement" "text" $(CONFIG_BTN_AGREEMENT)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "text" $(CONFIG_BTN_INSTALL)
- FunctionEnd
- Function initLicensePage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnAgree" "text" $(LICENSE_BTN_AGREE)
- FunctionEnd
- Function initInstallingPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "InstallingTitle" "bkimage" $(INSTALLING_TITLE)
- FunctionEnd
- Function initFinishPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "FinishPageTitle" "bkimage" $(FINISH_PAGE_TITLE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnRun" "text" $(BTN_RUN)
- FunctionEnd
- Function un.initUnInstallPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallTitle" "bkimage" $(UN_INSTALL_TITLE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallPrompt" "text" $(UN_INSTALL_PROMPT)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkbox_userdata" "text" $(UN_INSTALL_CHKBOX_USERDATA)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUnInstall" "text" $(BTN_CONFIRM)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUnClose" "text" $(BTN_CANCEL)
- FunctionEnd
- Function un.initUninstallingPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallingTitle" "bkimage" $(UN_INSTALL_TITLE)
- FunctionEnd
- Function un.initUninstallFinishPage
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallFinishTitle" "bkimage" $(UN_INSTALL_TITLE)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "unInstallFinishPrompt" "text" $(UN_INSTALL_FINISH_PROMPT)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUninstalled" "text" $(BTN_UNINSTALLED)
- nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnUninstalledReboot" "text" $(BTN_UNINSTALLED_REBOOT)
- FunctionEnd
|