zhengfuze

1. 插件安装文件。

git-svn-id: https://dev.3mang.com:543/svn/liveAssistant@12 ac0e06cd-bbdd-2244-bc7c-814b9d430a94
不能预览此文件类型
This file is too large to display.
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
This file is too large to display.
  1 +var pdtname
  2 +var pdtbrand
  3 +var pdtcompany
  4 +
  5 +!include "StrFunc.nsh"
  6 +# Declare used functions
  7 +${StrRep}
  8 +
  9 +;--------------------------------
  10 +;Include Modern UI
  11 +
  12 +!define PRODUCT_APP_PATH "Software\3mlive\client"
  13 +!define PRODUCT_NAME $pdtname
  14 +!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\3mlive"
  15 +!include "MUI.nsh"
  16 +
  17 +;--------------------------------
  18 +;General
  19 +
  20 +
  21 + ;Name and file
  22 + RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
  23 +
  24 + Name $pdtname
  25 +
  26 + OutFile "livesetup.exe"
  27 + BrandingText $pdtbrand
  28 + ;Default installation folder
  29 +
  30 + ;==================================
  31 + ; get app_dir
  32 +
  33 +;--------------------------------
  34 +;Interface Configuration
  35 +
  36 + !define MUI_HEADERIMAGE
  37 + !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp" ; optional
  38 + !define MUI_ABORTWARNING
  39 +
  40 +;--------------------------------
  41 +;Pages
  42 +;Languages
  43 + !insertmacro MUI_LANGUAGE "English" ;first language is the default language
  44 + !insertmacro MUI_LANGUAGE "SimpChinese"
  45 + !insertmacro MUI_LANGUAGE "TradChinese"
  46 +
  47 +; !insertmacro MUI_PAGE_LICENSE "License.txt"
  48 +; !insertmacro MUI_PAGE_COMPONENTS
  49 +; !insertmacro MUI_PAGE_DIRECTORY
  50 +
  51 +; !insertmacro MUI_PAGE_LICENSE $(MUILicense)
  52 + !insertmacro MUI_PAGE_INSTFILES
  53 +
  54 + !insertmacro MUI_UNPAGE_CONFIRM
  55 + !insertmacro MUI_UNPAGE_INSTFILES
  56 +
  57 +;--------------------------------
  58 +
  59 +
  60 +;Reserve Files
  61 +!insertmacro MUI_RESERVEFILE_LANGDLL
  62 +
  63 +;--------------------------------
  64 +;Installer Sections
  65 +
  66 +Section "Dummy Section" SecDummy
  67 +
  68 +
  69 + Var /GLOBAL os_ver
  70 + Var /GLOBAL app_dir
  71 +
  72 + SetShellVarContext current
  73 +
  74 + Call GetWindowsVersion
  75 + Pop $R0
  76 +
  77 +
  78 + StrCpy $os_ver $R0
  79 +
  80 + ;MessageBox MB_OK $os_ver
  81 +
  82 + StrCpy $app_dir "$PROGRAMFILES"
  83 +
  84 + StrCmp $os_ver "Vista" 0 VISTANEXT
  85 + ${StrRep} $app_dir $app_dir "Program Files" "ProgramData"
  86 +
  87 + Goto +2
  88 + VISTANEXT:
  89 + StrCmp $os_ver "win7" 0 WIN7NEXT
  90 + ${StrRep} $app_dir $app_dir "Program Files" "ProgramData"
  91 +
  92 + Goto +2
  93 + WIN7NEXT:
  94 + StrCmp $os_ver "win8" 0 WIN8NEXT
  95 + ${StrRep} $app_dir $app_dir "Program Files" "ProgramData"
  96 +
  97 + Goto +2
  98 + WIN8NEXT:
  99 +
  100 + CreateDirectory $app_dir\"3mlive\"
  101 +
  102 + SetOutPath $app_dir\"3mlive\"
  103 +
  104 + ExecWait '$app_dir\3mlive\livemgr.exe -uninstall'
  105 +
  106 + ;ADD YOUR OWN FILES HERE...
  107 + File .\files\*.*
  108 +
  109 + ;Create uninstaller
  110 + WriteUninstaller $app_dir\"3mlive\Uninstall.exe"
  111 +
  112 + ExecWait '$app_dir\3mlive\livemgr.exe -install'
  113 +
  114 + WriteRegStr HKCU "${PRODUCT_APP_PATH}" "app_data_path" "$app_dir\3mlive\"
  115 +
  116 + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}"
  117 + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$app_dir\3mlive\uninstall.exe"
  118 + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "3mlive"
  119 + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "www.3mang.com"
  120 + WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "3mlive"
  121 +
  122 + ;Create shortcuts
  123 + CreateDirectory "$SMPROGRAMS\3mlive"
  124 + CreateShortCut "$SMPROGRAMS\3mlive\Uninstall.lnk" "$app_dir\3mlive\Uninstall.exe"
  125 +
  126 +SectionEnd
  127 +
  128 +
  129 +Function .onInit
  130 +
  131 +
  132 +FunctionEnd
  133 +
  134 +Function un.onInit
  135 +
  136 +
  137 +FunctionEnd
  138 +
  139 +
  140 +Function GetWindowsVersion
  141 +
  142 + Push $R0
  143 + Push $R1
  144 +
  145 + ClearErrors
  146 +
  147 + ReadRegStr $R0 HKLM \
  148 + "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  149 +
  150 + IfErrors 0 lbl_winnt
  151 +
  152 + ; we are not NT
  153 + ReadRegStr $R0 HKLM \
  154 + "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
  155 +
  156 + StrCpy $R1 $R0 1
  157 + StrCmp $R1 '4' 0 lbl_error
  158 +
  159 + StrCpy $R1 $R0 3
  160 +
  161 + StrCmp $R1 '4.0' lbl_win32_95
  162 + StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98
  163 +
  164 + lbl_win32_95:
  165 + StrCpy $R0 '95'
  166 + Goto lbl_done
  167 +
  168 + lbl_win32_98:
  169 + StrCpy $R0 '98'
  170 + Goto lbl_done
  171 +
  172 + lbl_win32_ME:
  173 + StrCpy $R0 'ME'
  174 + Goto lbl_done
  175 +
  176 + lbl_winnt:
  177 +
  178 + StrCpy $R1 $R0 1
  179 +
  180 + StrCmp $R1 '3' lbl_winnt_x
  181 + StrCmp $R1 '4' lbl_winnt_x
  182 +
  183 + StrCpy $R1 $R0 3
  184 +
  185 + StrCmp $R1 '5.0' lbl_winnt_2000
  186 + StrCmp $R1 '5.1' lbl_winnt_XP
  187 + StrCmp $R1 '5.2' lbl_winnt_2003
  188 + StrCmp $R1 '6.1' lbl_win7
  189 + StrCmp $R1 '6.2' lbl_win8
  190 + StrCmp $R1 '6.3' lbl_win81
  191 + StrCmp $R1 '6.0' lbl_winnt_vista lbl_error
  192 +
  193 + lbl_winnt_x:
  194 + StrCpy $R0 "NT $R0" 6
  195 + Goto lbl_done
  196 +
  197 + lbl_winnt_2000:
  198 + StrCpy $R0 '2000'
  199 + Goto lbl_done
  200 +
  201 + lbl_winnt_XP:
  202 + StrCpy $R0 'XP'
  203 + Goto lbl_done
  204 +
  205 + lbl_winnt_2003:
  206 + StrCpy $R0 '2003'
  207 + Goto lbl_done
  208 +
  209 + lbl_win7:
  210 + StrCpy $R0 'win7'
  211 + Goto lbl_done
  212 +
  213 + lbl_win8:
  214 + StrCpy $R0 'win8'
  215 + Goto lbl_done
  216 +
  217 + lbl_win81:
  218 + StrCpy $R0 'win8'
  219 + Goto lbl_done
  220 +
  221 + lbl_winnt_vista:
  222 + StrCpy $R0 'Vista'
  223 + Goto lbl_done
  224 +
  225 + lbl_error:
  226 + StrCpy $R0 ''
  227 + lbl_done:
  228 +
  229 + Pop $R1
  230 + Exch $R0
  231 +
  232 + FunctionEnd
  233 +
  234 +
  235 +;--------------------------------
  236 +;Descriptions
  237 +
  238 + ;Language strings
  239 + LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."
  240 +
  241 + ;Assign language strings to sections
  242 + !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  243 + !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
  244 + !insertmacro MUI_FUNCTION_DESCRIPTION_END
  245 +
  246 +;--------------------------------
  247 +;Uninstaller Section
  248 +Section "Uninstall"
  249 +
  250 +
  251 + RMDir /r $INSTDIR
  252 + Delete $INSTDIR\Uninstall.exe
  253 +
  254 + Delete "$SMPROGRAMS\3mlive\Uninstall.lnk"
  255 + RMDir "$SMPROGRAMS\3mlive"
  256 +
  257 + DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
  258 +
  259 +SectionEnd