最新消息:

开源115浏览器使用例子

nsis 永恒心锁 1643浏览 0评论
;ExecShell taskbarunpin "$DESKTOP\${PRODUCT_NAME}.lnk"是删除任务栏图标

;安装包 解压空白
!system '>blank set/p=MSCF<nul' !packhdr="" temp.dat="" 'cmd="" c="" copy="" b="" +blank&&del="" blank'=""
${OrIf} $0 < 0
System::Int64Op $0 / 1024
Pop $0
StrCpy $1 "KB"
${If} $0 > 1024
${OrIf} $0 < 0
System::Int64Op $0 / 1024
Pop $0
StrCpy $1 "MB"
${If} $0 > 1024
${OrIf} $0 < 0
System::Int64Op $0 / 1024
Pop $0
StrCpy $1 "GB"
${EndIf}
${EndIf}
${EndIf}

StrCpy $FreeSpaceSize "$0$1"
FunctionEnd

Function FreshInstallDataStatusFunc
;更新磁盘空间文本显示
nsSkinEngine::FindControl "InstallTab_FreeSpace"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have InstallTab_FreeSpace"
${Else}
nsSkinEngine::SetControlData "InstallTab_FreeSpace" $FreeSpaceSize "text"
${EndIf}
;路径是否合法(合法则不为0Bytes)
${If} $FreeSpaceSize == "0Bytes"
nsSkinEngine::SetControlData "InstallTab_InstallBtn" "false" "enable"
${Else}
nsSkinEngine::SetControlData "InstallTab_InstallBtn" "true" "enable"
${EndIf}
FunctionEnd

Function OnTextChangeFunc
; 改变可用磁盘空间大小
nsSkinEngine::GetControlData InstallTab_InstallFilePath "text"
Pop $0
;MessageBox MB_OK $0
StrCpy $INSTDIR $0

;重新获取磁盘空间
Call UpdateFreeSpace
Call FreshInstallDataStatusFunc
FunctionEnd

Function OnInstallPathBrownBtnFunc
nsSkinEngine::GetControlData "InstallTab_InstallFilePath" "text" ;
Pop $installPath
nsSkinEngine::SelectFolderDialog "请选择文件夹" $installPath
Pop $installPath

StrCpy $0 $installPath
${If} $0 == "-1"
${Else}
StrCpy $INSTDIR "$installPath\${PRODUCT_NAME_EN}"
;设置安装路径编辑框文本
nsSkinEngine::FindControl "InstallTab_InstallFilePath"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have Wizard_InstallPathBtn4Page2 button"
${Else}
;nsSkinEngine::SetText2Control "InstallTab_InstallFilePath" $installPath
StrCpy $installPath $INSTDIR
nsSkinEngine::SetControlData "InstallTab_InstallFilePath" $installPath "text"
${EndIf}
${EndIf}

;重新获取磁盘空间
Call UpdateFreeSpace
Call FreshInstallDataStatusFunc
FunctionEnd

Function OnCheckChanged
nsSkinEngine::GetControlData "CustomOptionsCheckBox" "Checked" ;
Pop $0
${If} $0 == "1"
nsSkinEngine::NSISResize "445" "608"
nsSkinEngine::SetControlData "customVer" "true" "visible"
${Else}
nsSkinEngine::NSISResize "445" "462"
nsSkinEngine::SetControlData "customVer" "false" "visible"
${EndIf}
FunctionEnd

Function acceptCheckChangedFunc
nsSkinEngine::GetControlData "acceptCheckBox" "Checked" ;
Pop $0
${If} $0 == "1"
nsSkinEngine::SetControlData "InstallBtn" "true" "enable"
${Else}
nsSkinEngine::SetControlData "InstallBtn" "false" "enable"
${EndIf}
FunctionEnd

Function acceptPageFunc
nsSkinEngine::SetControlData "windowbk" "1" "TabCurrentIndexInt"
nsSkinEngine::ShowLicense "acceptInfo" "license.txt"
FunctionEnd

Function acceptOkFunc
nsSkinEngine::SetControlData "windowbk" "0" "TabCurrentIndexInt"
FunctionEnd

Function InstallPageFunc
nsSkinEngine::SetControlData "InstallTab_sysCloseBtn" "false" "enable"
nsSkinEngine::NSISResize "445" "462"
nsSkinEngine::SetControlData "customVer" "false" "visible"
Call OnNextBtnFunc
;设置进度条
nsSkinEngine::SetControlData "CompleteTab_RunAppCheckBox" "true" "Checked" ;默认勾选运行程序
nsSkinEngine::FindControl "InstallProgressBar"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have InstallProgressBar"
${Else}
nsSkinEngine::SetControlData "InstallProgressBar" "0" "ProgressInt"
nsSkinEngine::SetControlData "progressText" "0%" "text"
nsSkinEngine::NSISStopMsgLoop
${EndIf}
FunctionEnd

Function InstallShow
nsSkinEngine::FindControl "InstallProgressBar"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have InstallProgressBar"
${Else}
nsSkinEngine::NSISBindingProgress "InstallProgressBar" "progressText"
${EndIf}
FunctionEnd

Section InstallFiles
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File /r "bin\*.*"
SectionEnd

Section RegistKeys
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\${MAIN_APP_NAME}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${MAIN_APP_NAME},0"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

Section CreateShorts
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
SetShellVarContext all
;创建开始菜单快捷方式
CreateDirectory "$SMPROGRAMS\Google Translate"
CreateShortCut "$SMPROGRAMS\Google Translate\${PRODUCT_NAME}.lnk" "$INSTDIR\${MAIN_APP_NAME}"
CreateShortCut "$SMPROGRAMS\Google Translate\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\Google Translate\Uninstall.lnk" "$INSTDIR\uninst.exe"
SetOverwrite ifnewer
nsSkinEngine::GetControlData "deskShortCheckBox" "Checked" ;
Pop $0
${If} $0 == "1"
;创建桌面快捷方式
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${MAIN_APP_NAME}"
${EndIf}

/* CreateShortCut "$QUICKLAUNCH\${PRODUCT_NAME}.lnk" "$INSTDIR\${MAIN_APP_NAME}"
System::Call 'shell32.dll::ShellExecute(i 0, t "taskbarpin", t "$QUICKLAUNCH\${PRODUCT_NAME}.lnk", i 0, i 0, i 0) i .r1 ?e' */
Call RefreshShellIcons
SectionEnd

Section Finish
nsSkinEngine::SetControlData "InstallTab_sysCloseBtn" "true" "enable"
nsSkinEngine::GetControlData "2345CheckBox" "Checked" ;
Pop $0
${If} $0 == "1"
;设置浏览器首页
WriteRegStr HKCU "Software\Microsoft\Internet Explorer\Main" "Start Page" "${PRODUCT_2345WEB_SITE}"
${EndIf}
SectionEnd

Function OnCompleteBtnFunc
nsSkinEngine::HideNSISSkinEngine
nsSkinEngine::StopAnimationBkControl
nsSkinEngine::GetControlData "autoCheckBox" "Checked" ;
Pop $0
${If} $0 == "1"
WriteRegStr HKCU "${PRODUCT_AUTORUN_KEY}" "${PRODUCT_NAME}" "$INSTDIR\${MAIN_APP_NAME} -mini"
${EndIf}

Exec '"$INSTDIR\${MAIN_APP_NAME}"'
nsSkinEngine::ExitNSISSkinEngine "false"
FunctionEnd
Function un.accept
nsSkinEngine::NSISSendMessage $Dialog WM_NSISOPENURL "http://www.yhxs3344.net/";
FunctionEnd
;-----------------------------------------------------------------------------------------------------------------------------

Function un.onInit
;创建互斥防止重复运行
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "aceuiUnInstall") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "有一个 115浏览器 卸载向导已经运行!"
Abort

SetOutPath "${UNINSTALL_DIR}"
File /r /x *.db ".\resouce\115Browser\*.*"

KillProcDLL::KillProc "${MAIN_APP_NAME}" ;强制结束进程
FunctionEnd

Function un.UninstallProgress
nsSkinEngine::InitNSISSkinEngine /NOUNLOAD "${UNINSTALL_DIR}" "UninstallPackages.xml" "WizardTab" "false" "115浏览器" "7B4D2AD97EC46776D7504B1F501B17483E5EFD52B3BA9E8BE9D6401E4F742E19B822CC7DDF6FC224A5D8AAFB9FFC899B" "app.ico" "true"
Pop $Dialog
;初始化MessageBox窗口
nsSkinEngine::InitNSISMessageBox "MessageBox.xml" "TitleLab" "TextLab" "CloseBtn" "YESBtn" "NOBtn"
Pop $MessageBoxHandle

;关闭按钮绑定函数
nsSkinEngine::FindControl "sysCloseBtn"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have sysCloseBtn"
${Else}
GetFunctionAddress $0 un.OnUnInstallCancelFunc
nsSkinEngine::OnControlBindNSISScript "sysCloseBtn" $0
${EndIf}

;取消按钮绑定函数
nsSkinEngine::FindControl "cancelUninstallBtn"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have cancelUninstallBtn"
${Else}
GetFunctionAddress $0 un.OnUnInstallCancelFunc
nsSkinEngine::OnControlBindNSISScript "cancelUninstallBtn" $0
${EndIf}

;残忍卸载 okUninstallBtn
nsSkinEngine::FindControl "okUninstallBtn"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have okUninstallBtn"
${Else}
GetFunctionAddress $0 un.UnInstallPageFunc
nsSkinEngine::OnControlBindNSISScript "okUninstallBtn" $0
${EndIf}

;卸载完成 completeBtn
nsSkinEngine::FindControl "completeBtn"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have completeBtn"
${Else}
GetFunctionAddress $0 un.OnCompleteBtnFunc
nsSkinEngine::OnControlBindNSISScript "completeBtn" $0
${EndIf}

;--------------------------------------窗体显示-----------------------------------
nsSkinEngine::RunNSISSkinEngine
FunctionEnd

Function un.OnUnInstallCancelFunc
nsSkinEngine::ExitNSISSkinEngine
FunctionEnd

Function un.OnNextBtnFunc
nsSkinEngine::NSISSendMessage $Dialog WM_NSISNEXT
FunctionEnd

Function un.UnInstallPageFunc
Call un.OnNextBtnFunc
nsSkinEngine::NSISStopMsgLoop
FunctionEnd

Function un.UninstallNow
nsSkinEngine::FindControl "UnInstallProgressBar"
Pop $0
${If} $0 == "-1"
MessageBox MB_OK "Do not have UnInstallProgressBar"
${Else}
nsSkinEngine::NSISBindingProgress "UnInstallProgressBar" "progressText"
${EndIf}
FunctionEnd

Section "Uninstall"
# 设置为当前用户
SetShellVarContext current
# 设置为所有用户
SetShellVarContext all

Delete "$SMPROGRAMS\Google Translate\*.lnk"
Delete "$SMPROGRAMS\Google Translate\Uninstall.lnk"
Delete "$SMPROGRAMS\Google Translate\Website.lnk"
Delete "$SMPROGRAMS\Google Translate\${PRODUCT_NAME}.lnk"
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
RMDir /r /REBOOTOK "$SMPROGRAMS\Google Translate"
RMDir /r /REBOOTOK "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Google Translate"
DeleteRegValue HKCU "${PRODUCT_AUTORUN_KEY}" "${PRODUCT_NAME}"

SectionEnd

Function un.OnCompleteBtnFunc
nsSkinEngine::HideNSISSkinEngine
;Call un.SendStatistics
;Call un.DeleteRegKey ;发送完统计再调用删除key,因为发送可能需要某些键值
nsSkinEngine::ExitNSISSkinEngine
FunctionEnd

;刷新关联图标
Function RefreshShellIcons
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd

Function .onInstSuccess
FunctionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 开源115浏览器使用例子

您必须 登录 才能发表评论!