最新消息:

蓝色网际liveupdate软件更新脚本

nsis 永恒心锁 1798浏览 0评论
;脚本编写: 蓝色网际

;-------------------------------------------------

;!define Test

!define STR_REGKEY   'HKCU "Software$(^NameDA)"'

;-------------------------------------------------

Name                 "Simple LiveUpdate"

Caption              "$(^NameDA)"

BrandingText         "$(^NameDA) ${__DATE__}"

OutFile              "LiveUpdate.exe"

SetCompressor        lzma

ShowInstDetails      show

;保存文件在最后的数据区块,初始化时加快速度

ReserveFile          ".resourceliveupdate.ini"

ReserveFile          ".resourceliveupdate2.ini"

ReserveFile          "${NSISDIR}PluginsSystem.dll"

ReserveFile          ".resourceunrar.exe"

Var HWND

Var OS

Var Type

Var Path

Var AUTO

Var URL

Var GroupName

Var GroupVer

Var OutPath

Var Local

!include "MUI2.nsh"

!include "Sections.nsh"

!include "Language.nsi"

!include "GetMetaEntry.nsi"

!define MUI_ICON ".resourceico-lud.ico"

!define MUI_HEADERIMAGE

!define MUI_HEADERIMAGE_BITMAP ".resourceNsisGreenCD1.bmp"

!define MUI_CUSTOMFUNCTION_ABORT Exit2

Page custom SetCustom LeaveCustom

!define MUI_PAGE_HEADER_TEXT "$(STR_INSTALLING_TITLE)"

!define MUI_PAGE_HEADER_SUBTEXT "$(STR_INSTALLING_SUBTITLE)"

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

!insertmacro MUI_LANGUAGE "SimpChinese"

!insertmacro MUI_RESERVEFILE_LANGDLL

;-----------------------------------------------------------------

!macro dl File Silence

!define dlline ${__LINE__}

ReadINIStr $R2 "$PLUGINSDIRliveupdate.ini" "Field 2" "State"

NSISdl::download${Silence} /TRANSLATE "$(DL_TRANSLATE1)" "$(DL_TRANSLATE2)" "$(DL_TRANSLATE3)" "$(DL_TRANSLATE4)" "$(DL_TRANSLATE5)" "$(DL_TRANSLATE6)" "$(DL_TRANSLATE7)" "$(DL_TRANSLATE8)" /TIMEOUT=$R2 "$URL/${File}" "$PLUGINSDIR${File}"

Pop $R0

StrCmp $R0 "success" dl_succes_${dlline}

StrCmp $R0 "resolving hostname" dl_error2_${dlline}

StrCmp $R0 "connecting to host" dl_error3_${dlline}

StrCmp $R0 "downloading timed out" dl_error4_${dlline}

StrCmp $R0 "Downloading timed out." dl_error4_${dlline}

StrCmp $R0 "cancel" dl_error5_${dlline}

dl_error_${dlline}:

MessageBox MB_OK|MB_ICONSTOP "$(DL_ERROR1): $R0"

Call Exit

dl_error2_${dlline}:

MessageBox MB_OK|MB_ICONSTOP "$(DL_ERROR2)"

Call Exit

dl_error3_${dlline}:

MessageBox MB_OK|MB_ICONSTOP "$(DL_ERROR3)"

Call Exit

dl_error4_${dlline}:

MessageBox MB_OK|MB_ICONSTOP "$(DL_ERROR4)"

Call Exit

dl_error5_${dlline}:

MessageBox MB_OK|MB_ICONSTOP "$(DL_ERROR5)"

Call Exit

dl_succes_${dlline}:

IfFileExists "$PLUGINSDIR${File}" 0 dl_error_${dlline}

!undef dlline

!macroend

!macro SetOutPath

StrCmp $OutPath "" +4

SetDetailsPrint none

SetOutPath $OutPath

SetDetailsPrint both

!macroend

; -----------------------------------------------------------------------------------------

Function .onInit

IfSilent 0 +3 ;禁止静默模式

MessageBox MB_OK|MB_ICONEXCLAMATION "$(MB_DISABLE_SLIENT)"

Quit

InitPluginsDir

Push $CMDLINE

Push " /nt"

Call SearchStr

Pop $0

StrCmp $0 1 0 no_lang

Push $CMDLINE

Push " /lang"

Call SearchStr

Pop $0

StrCmp $0 1 0 no_lang

!insertmacro MUI_LANGDLL_DISPLAY

no_lang:

StrCmp $LANGUAGE 1033 0 not_eng

File /oname=$PLUGINSDIRliveupdate.ini ".resourceliveupdate2.ini"

not_eng:

StrCmp $LANGUAGE 2052 0 not_chs

File /oname=$PLUGINSDIRliveupdate.ini ".resourceliveupdate.ini"

not_chs:

ReadRegStr $0 ${STR_REGKEY} ""

StrCmp $0 "" no_setting

;读取用户以前的设置

ReadRegStr $0 ${STR_REGKEY} TimeOut

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 2" "State"  $0

ReadRegStr $0 ${STR_REGKEY} WriteLog

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 9" "State" "$0"

ReadRegStr $0 ${STR_REGKEY} ViewLog

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 8" "State" "$0"

ReadRegStr $0 ${STR_REGKEY} ProxyEnable

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 4" "State" "$0"

ReadRegStr $0 ${STR_REGKEY} ProxyServer

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 6" "State" "$0"

no_setting:

Call GetParameters

Pop $0

ReadINIStr $1 "$PLUGINSDIRsetting.ini" "setting" NoTemp

StrCmp $1 1 no_temp

System::Call 'kernel32::GetModuleFileNameA(i 0, t .r2, i 1024) i r1'

Pop $2

CopyFiles /SILENT $2 $TEMP

Push $2

Call GetFileName

Pop $2

Exec "$TEMP$2 /$0 /nt"

Quit

no_temp:

System::Call 'kernel32::CreateMutexA(i 0, i 0, t "SLUPD") i .r1 ?e'

Pop $0

StrCmp $0 0 +3

MessageBox MB_OK|MB_ICONEXCLAMATION "$(MB_ALREADY_RUNNING)"

Quit

FunctionEnd

; -----------------------------------------------------------------------------------------

#!define BM_GETSTATE                 0x00F2

#!define BM_SETCHECK                 0x00F1

#!define CB_GETCURSEL                0x0147

#!define CB_SETCURSEL                0x014E

Function SetCustom

StrCmp $AUTO 1 the_end

GetDlgItem $0 $HWNDPARENT 1

SendMessage $0 ${WM_SETTEXT} 0 "STR:$(CUSTOM_PAGE_BUTTON)"

InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIRliveupdate.ini"

Pop $HWND

!insertmacro MUI_HEADER_TEXT "$(CUSTOM_PAGE_TITLE)" "$(CUSTOM_PAGE_SUBTITLE)"

ReadINIStr $R0 "$PLUGINSDIRliveupdate.ini" "Field 4" "State"

StrCmp $R0 1 +2

StrCpy $R0 0

GetDlgItem $R1 $HWND 1205

EnableWindow $R1 $R0

ReadINIStr $R0 "$PLUGINSDIRliveupdate.ini" "Field 9" "State"

StrCmp $R0 1 +2

StrCpy $R0 0

GetDlgItem $R1 $HWND 1207

EnableWindow $R1 $R0

ReadRegStr $0 ${STR_REGKEY} ""

StrCmp $0 "" no_setting

ReadRegStr $Type ${STR_REGKEY} UpdateType

;------------------------ 旧的记忆方式

StrCmp $Type "暴风影音" +2

StrCmp $Type "Storm Codec" 0 +2

StrCpy $Type 0

Goto +3

StrCmp $Type "foobar2000" 0 +2

StrCpy $Type 1

;------------------------

GetDlgItem $0 $HWND 1210

SendMessage $0 ${CB_SETCURSEL} $Type 0

no_setting:

InstallOptions::show

the_end:

FunctionEnd

; -----------------------------------------------------------------------------------------

Function LeaveCustom

ReadINIStr $R0 "$PLUGINSDIRliveupdate.ini" "Field 11" "State"

StrCmp $R0 "" 0 +3

MessageBox MB_ICONEXCLAMATION|MB_OK "$(MB_SEL_SOFTWARE)"

Abort

ReadINIStr $R0 "$PLUGINSDIRliveupdate.ini" "Settings" "State"

StrCmp $R0 0 validate

StrCmp $R0 4 textbox

StrCmp $R0 9 checkbox

Abort

textbox:

ReadINIStr $R0 "$PLUGINSDIRliveupdate.ini" "Field 4" "State"

StrCmp $R0 1 +2

StrCpy $R0 0

GetDlgItem $R1 $HWND 1205

EnableWindow $R1 $R0

Abort

checkbox:

ReadINIStr $R0 "$PLUGINSDIRliveupdate.ini" "Field 9" "State"

StrCmp $R0 1 +2

StrCpy $R0 0

GetDlgItem $R1 $HWND 1207

SendMessage $R1 ${BM_SETCHECK} $R0 0

EnableWindow $R1 $R0

Abort

validate:

GetDlgItem $0 $HWND 1210

SendMessage $0 ${CB_GETCURSEL} -1 0 $Type

StrCmp $Type "" 0 +2

Abort

FunctionEnd

;****************************************************************************************

Section "保存设置"

WriteRegStr ${STR_REGKEY} "" 1

WriteRegStr ${STR_REGKEY} UpdateType $Type

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 2" "State"

WriteRegStr ${STR_REGKEY} TimeOut $0

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 9" "State"

WriteRegStr ${STR_REGKEY} WriteLog $0

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 8" "State"

WriteRegStr ${STR_REGKEY} ViewLog $0

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 4" "State"

WriteRegStr ${STR_REGKEY} ProxyEnable $0

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 6" "State"

WriteRegStr ${STR_REGKEY} ProxyServer "$0"

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 4" "State"   ;替换 IE 代理

StrCmp $0 1 0 no_proxy

ReadRegDWORD $0 HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyEnable

WriteRegDWORD HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyEnable_Backup "$0"

ReadRegStr $0 HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer

StrCmp $0 "" 0 +2

WriteRegStr HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer_NONE 1

WriteRegStr HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer_Backup "$0"

WriteRegDWORD HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyEnable 1

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 6" "State"

WriteRegStr HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer "http=$0"

no_proxy:

SectionEnd

;----------------------------------------------------------------------------------------

Section "初始化"

GetDlgItem $0 $HWNDPARENT 2 ;允许取消按钮

EnableWindow $0 1

SetDetailsPrint none

File /oname=$PLUGINSDIRunrar.exe ".resourceunrar.exe"

SetDetailsPrint both

;---------------------------------------------------------------

StrCmp $AUTO 1 auto_close

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 9" "State"

ReadINIStr $1 "$PLUGINSDIRliveupdate.ini" "Field 8" "State"

IntOp $0 $0 && $1

StrCmp $0 1 auto_close

SetAutoClose         false

Goto +3

auto_close:       ;检测是否需要自动关闭

SetAutoClose         true

;---------------------------------------------------------------

StrCpy $0 1 ;这个命令会无效

Call GetWinVer

Pop $OS     ;Windows 平台 9X 或 NT

Pop $0     ;系统详细信息

StrCmp $0 "" +2

DetailPrint "$(DP_DETECT_OS): $0"

DetailPrint "$(DP_INIT)"

StrCmp $Type 0 storm

StrCmp $Type 1 foobar2000

;$0 软件版本(本地)

;$2 信息文件

;$Path 路径

storm:

ReadRegStr $Path HKLM "SoftwareStorm Codec" "Path"

ReadRegStr $0 HKLM "SoftwareStorm CodecVersion" ""

StrCpy $2 "$(INFO_STORM)"

StrCmp $URL "" 0 +2

StrCpy $URL "http://www.sbtop.com/liveupdate"

Goto type_end

foobar2000:

ReadRegStr $Path HKLM "SoftwareMicrosoftWindowsCurrentVersionUninstallfoobar2000" "InstallDir"

ReadINIStr $0 "$Pathinstaller.ini" foobar2000 haversion

StrCpy $2 info_fb2k.rar

StrCmp $URL "" 0 +2

StrCpy $URL "http://foobar.nease.net/liveupdate"

type_end:

StrCmp $0 "" 0 +3

MessageBox MB_OK|MB_ICONSTOP "$(MB_LOST_VER_INFO)"

Call Exit

StrCmp $Path "" 0 +3

MessageBox MB_OK|MB_ICONSTOP  "$(MB_LOST_PATH_INFO)"

Call Exit

;如果检测到的路径后面带有 则去掉

StrCpy $3 $Path "" -1

StrCmp $3 '' 0 +2

StrCpy $Path $Path -1

StrCmp $Local 1 local

DetailPrint "$(DP_GET_INFO)"

!insertmacro dl $2 _quiet

Goto +3

local:

SetDetailsPrint none

CopyFiles "$EXEDIR$2" $PLUGINSDIR

SetDetailsPrint none

SetOutPath $PLUGINSDIR

nsExec::Exec 'unrar e $2 '

SetDetailsPrint both

;检测服务器版本是否超过限制

ReadINIStr $3 "$PLUGINSDIRinfo.txt" Start Version

StrCmp $3 NOUPDATE 0 +3

MessageBox MB_OK|MB_ICONEXCLAMATION "$(DP_NO_UPD)"

Call Exit

StrCmp $3 "" +5

StrCmp $3 NONE +4

Push $3

Push $0

Call CheckVer

SectionEnd

;--------------------------------------------------------------------------

Section "更新"

GetDlgItem $0 $HWNDPARENT 2 ;允许取消按钮

EnableWindow $0 1

Call Main

SectionEnd

;--------------------------------------------------------------------------

Function Main

Push $0

Push $1 ;文件指针

Push $2

StrCpy $1 0

Call SkipGroup

loop:

Call ReadFile

Pop $0

StrCmp $0 "" loop_quit

StrLen $2 $0

IntOp $1 $1 + $2

Push $0

Call TrimLine

Pop $0

StrCmp $0 "" loop

Push $0

Call GetMetaEntry

Pop $0

StrCmp $ME_TEMP2 "" +4

Push $ME_TEMP2

Call ChangeVar

Pop $ME_TEMP2

StrCmp $ME_TEMP3 "" +4

Push $ME_TEMP3

Call ChangeVar

Pop $ME_TEMP3

StrCmp $ME_TEMP4 "" +4

Push $ME_TEMP4

Call ChangeVar

Pop $ME_TEMP4

StrCmp $ME_TEMP5 "" +4

Push $ME_TEMP5

Call ChangeVar

Pop $ME_TEMP5

StrCmp $ME_TEMP6 "" +4

Push $ME_TEMP6

Call ChangeVar

Pop $ME_TEMP6

StrCmp $ME_TEMP7 "" +4

Push $ME_TEMP7

Call ChangeVar

Pop $ME_TEMP7

StrCmp $ME_TEMP1 Group 0 +3

Call Group

Goto loop

StrCmp $ME_TEMP1 SetOutPath 0 +3

Call SetOutPath

Goto loop

StrCmp $ME_TEMP1 File 0 +3

Call File

Goto loop

StrCmp $ME_TEMP1 WriteRegStr 0 +3

Call WriteRegStr

Goto loop

StrCmp $ME_TEMP1 WriteRegDWORD 0 +3

Call WriteRegDWORD

Goto loop

StrCmp $ME_TEMP1 WriteRegBin 0 +3

Call WriteRegBin

Goto loop

StrCmp $ME_TEMP1 RegDLL 0 +3

RegDLL $ME_TEMP2

Goto loop

StrCmp $ME_TEMP1 UnRegDLL 0 +3

UnRegDLL $ME_TEMP2

Goto loop

StrCmp $ME_TEMP1 Delete 0 +3

Delete /REBOOTOK $ME_TEMP2

Goto loop

StrCmp $ME_TEMP1 DelRegKey 0 +3

Call DelRegKey

Goto loop

StrCmp $ME_TEMP1 DelRegValue 0 +3

Call DelRegValue

Goto loop

StrCmp $ME_TEMP1 RMDir 0 +3

Call RMDir

Goto loop

StrCmp $ME_TEMP1 WriteINI 0 +3

Call WriteINI

Goto loop

StrCmp $ME_TEMP1 DelINI 0 +3

Call DelINI

Goto loop

StrCmp $ME_TEMP1 CreateShortCut 0 +3

Call CreateShortCut

Goto loop

StrCmp $ME_TEMP1 IfOS 0 +3

Call IfOS

Goto loop

StrCmp $ME_TEMP1 IfFileExists 0 +3

Call IfFileExists

Goto loop

StrCmp $ME_TEMP1 ExecShell 0 +3

Call ExecShell

Goto loop

StrCmp $ME_TEMP1 Exec 0 +3

Call Exec

Goto loop

StrCmp $ME_TEMP1 ExecWait 0 +3

Call ExecWait

Goto loop

loop_quit:

!ifndef Test ;测试时不更新版本

StrCmp $GroupName "" wrtie_info_end

StrCmp $GroupVer "" wrtie_info_end

;写新版本信息

StrCmp $Type 0 +2

WriteRegStr HKLM "SoftwareStorm CodecVersion" $GroupName $GroupVer

Goto wrtie_info_end

StrCmp $Type 1 0 wrtie_info_end

WriteINIStr "$Pathinstaller.ini" Date $GroupName $GroupVer

wrtie_info_end:

!endif

Pop $2

Pop $1

Pop $0

FunctionEnd

;-----------------------------------------------------------------------------------------

Section "TheEnd"

ReadINIStr $0 "$PLUGINSDIRliveupdate.ini" "Field 9" "State"

StrCmp $0 0 +2

Call WriteLog

Call Exit2

Call RefreshShellIcons

SectionEnd

;******************************************************************************

Function SearchStr

Exch $R0 ;要查找的字串

Exch

Exch $R1 ;要在里面查找的字串

Push $R2

Push $R3

Push $R4

Push $R5

StrCpy $R2 0

StrLen $R3 $R0

StrLen $R4 $R1

loop:

StrCpy $R5 $R1 $R3 $R2

StrCmp $R5 $R0 done

IntCmp $R2 $R4 loop_quit 0 loop_quit

IntOp $R2 $R2 + 1

Goto loop

done:

StrCpy $R0 1

Goto end

loop_quit:

StrCpy $R0 0

end:

Pop $R5

Pop $R4

Pop $R3

Pop $R2

Pop $R1

Exch $R0

FunctionEnd

;-----------------------------------------------------------------------------------------

Function GetFileName

Exch $R0

Push $R1

Push $R2

Push $R3

StrCpy $R1 1

StrLen $R2 $R0

loop:

StrCpy $R3 $R0 1 -$R1

StrCmp $R3 "" loop_quit

IntCmp $R1 $R2 loop_quit 0 loop_quit

IntOp $R1 $R1 + 1

Goto loop

loop_quit:

IntOp $R1 $R1 - 1

StrCpy $R0 $R0 "" -$R1

Pop $R3

Pop $R2

Pop $R1

Exch $R0

FunctionEnd

;-----------------------------------------------------------------------------------------

Function CheckVer

Pop $R0 ;本地版本

Pop $R1 ;服务器版本

Push $R2 ;本地版本偏移

Push $R3 ;服务器版本偏移

Push $R4

Push $R5

Push $R6

StrCpy $R2 0

StrCpy $R3 0

loop:

StrCpy $R4 $R0 1 $R2

StrCmp $R4 . loop_quit

StrCmp $R4 "" loop_quit

IntOp $R2 $R2 + 1

Goto loop

loop_quit:

StrCpy $R5 $R0 $R2

IntOp $R2 $R2 + 1

StrCpy $R0 $R0 "" $R2

StrCpy $R2 0

loop2:

StrCpy $R4 $R1 1 $R3

StrCmp $R4 . loop2_quit

StrCmp $R4 "" last

IntOp $R3 $R3 + 1

Goto loop2

loop2_quit:

StrCpy $R6 $R1 $R3

IntOp $R3 $R3 + 1

StrCpy $R1 $R1 "" $R3

StrCpy $R3 0

IntCmp $R5 $R6 loop not_match end

last:

StrCpy $R6 $R1 $R3

IntCmp $R5 $R6 end 0 end

not_match:

MessageBox MB_OK|MB_ICONEXCLAMATION "$(MB_VER_NOT_MATCH)"

ReadINIStr $R0 "$PLUGINSDIRinfo.txt" Start UpdateURL

StrCmp $R0 "" +3

MessageBox MB_YESNO "$(MB_NOW_OPEN)" IDNO +2

ExecShell open $R0

Call Exit

end:

Pop $R6

Pop $R5

Pop $R4

Pop $R3

Pop $R2

Pop $R1

Pop $R0

FunctionEnd

;-----------------------------------------------------------------------------------------

Function Group

!ifndef Test ;测试时不更新版本

StrCmp $GroupName "" wrtie_info_end

StrCmp $GroupVer "" wrtie_info_end

;写新版本信息

StrCmp $Type 0 +2

WriteRegStr HKLM "SoftwareStorm CodecVersion" $GroupName $GroupVer

Goto wrtie_info_end

StrCmp $Type 1 0 wrtie_info_end

WriteINIStr "$Pathinstaller.ini" Date $GroupName $GroupVer

wrtie_info_end:

!endif

StrCpy $GroupName $ME_TEMP2

StrCmp $GroupName "" group_end

;读当前版本信息

StrCmp $Type 0 +2

ReadRegStr $R0 HKLM "SoftwareStorm CodecVersion" $GroupName

Goto read_info_end

StrCmp $Type 1 0 read_info_end

ReadINIStr $R0 "$Pathinstaller.ini" Date $GroupName

read_info_end:

StrCmp $R0 "" 0 +5

DetailPrint "$(DP_NO_GROUP) $GroupName"

Call SkipGroup

StrCpy $GroupVer ""

Goto group_end

StrCpy $GroupVer $ME_TEMP3

StrCmp $GroupVer "" group_end

IntCmp $GroupVer $R0 0 0 +4

DetailPrint "$GroupName $(DP_NO_UPD)"

Call SkipGroup

Goto group_end

DetailPrint "$GroupName $(DP_HAVE_UPD)"

group_end:

FunctionEnd

;-----------------------------------------------------------------------------------------

Function SetOutPath

SetOutPath $ME_TEMP2

StrCpy $OutPath $ME_TEMP2

FunctionEnd

;-----------------------------------------------------------------------------------------

Function ExecShell

SetDetailsPrint none

StrCmp $ME_TEMP4 "" 0 +3

ExecShell Open $ME_TEMP2 $ME_TEMP3

Goto end

StrCmp $ME_TEMP4 SW_SHOWNORMAL 0 +3

ExecShell Open $ME_TEMP2 $ME_TEMP3 SW_SHOWNORMAL

Goto end

StrCmp $ME_TEMP4 SW_SHOWMAXIMIZED 0 +3

ExecShell Open $ME_TEMP2 $ME_TEMP3 SW_SHOWMAXIMIZED

Goto end

StrCmp $ME_TEMP4 SW_SHOWMINIMIZED 0 +2

ExecShell Open $ME_TEMP2 $ME_TEMP3 SW_SHOWMINIMIZED

end:

SetDetailsPrint both

FunctionEnd

;-----------------------------------------------------------------------------------------

Function Exec

SetDetailsPrint none

StrCmp $ME_TEMP3 "" 0 +3

Exec $ME_TEMP2

Goto +2

Exec '"$ME_TEMP2" $ME_TEMP3'

SetDetailsPrint both

FunctionEnd

;-----------------------------------------------------------------------------------------

Function ExecWait

SetDetailsPrint none

StrCmp $ME_TEMP3 "" 0 +3

ExecWait $ME_TEMP2

Goto +2

ExecWait '"$ME_TEMP2" $ME_TEMP3'

SetDetailsPrint both

FunctionEnd

;-----------------------------------------------------------------------------------------

Function IfFileExists

Push $R0

Push $R1

StrCpy $ME_TEMP3 $ME_TEMP3 "" 1

StrCpy $ME_TEMP4 $ME_TEMP4 "" 1

IntOp $ME_TEMP3 $ME_TEMP3 - 1

IntOp $ME_TEMP4 $ME_TEMP4 - 1

IfFileExists $ME_TEMP2 0 +4

Push $ME_TEMP3

Call JumpLine

Goto +3

Push $ME_TEMP4

Call JumpLine

Pop $R1

Pop $R0

FunctionEnd

;-----------------------------------------------------------------------------------------

Function IfOS

Push $R0

Push $R1

StrCpy $ME_TEMP3 $ME_TEMP3 "" 1

StrCpy $ME_TEMP4 $ME_TEMP4 "" 1

IntOp $ME_TEMP3 $ME_TEMP3 - 1

IntOp $ME_TEMP4 $ME_TEMP4 - 1

Call GetWinVer

Pop $R0 ;NT、9X

Pop $R1

StrCmp $ME_TEMP2 $R0 0 +4

Push $ME_TEMP3

Call JumpLine

Goto +3

Push $ME_TEMP4

Call JumpLine

Pop $R1

Pop $R0

FunctionEnd

;-----------------------------------------------------------------------------------------

Function JumpLine

Exch $R0

Push $R1

Push $R2

IntCmp $R0 0 loop_quit loop_quit ;小于等于 0 则跳过

StrCpy $R1 0

loop:

IntCmp $R1 $R0 loop_quit 0 loop_quit

Call ReadFile

Pop $R2

StrLen $R2 $R2

IntOp $1 $1 + $R2

IntOp $R1 $R1 + 1

Goto loop

loop_quit:

Pop $R2

Pop $R1

Pop $R0

FunctionEnd

;-----------------------------------------------------------------------------------------

Function RMDir

StrCmp $ME_TEMP3 /r 0 +3

RMDir /r $ME_TEMP2

Goto end

StrCmp $ME_TEMP3 /REBOOTOK 0 +3

RMDir /REBOOTOK $ME_TEMP2

Goto end

RMDir $ME_TEMP2

end:

FunctionEnd

;-----------------------------------------------------------------------------------------

!macro CreateShortCut INDEX

StrCmp $ME_TEMP6 ${INDEX} 0 +3

CreateShortCut "$ME_TEMP2.lnk" $ME_TEMP3 $ME_TEMP4 $ME_TEMP5 ${INDEX} "" "" $ME_TEMP7

Goto the_end

!macroend

Function CreateShortCut

ClearErrors

!insertmacro CreateShortCut 1

!insertmacro CreateShortCut 2

!insertmacro CreateShortCut 3

!insertmacro CreateShortCut 4

!insertmacro CreateShortCut 5

!insertmacro CreateShortCut 6

!insertmacro CreateShortCut 7

!insertmacro CreateShortCut 8

!insertmacro CreateShortCut 9

!insertmacro CreateShortCut 10

!insertmacro CreateShortCut 11

!insertmacro CreateShortCut 12

!insertmacro CreateShortCut 13

!insertmacro CreateShortCut 14

!insertmacro CreateShortCut 15

!insertmacro CreateShortCut 16

!insertmacro CreateShortCut 17

!insertmacro CreateShortCut 18

!insertmacro CreateShortCut 19

!insertmacro CreateShortCut 20

!insertmacro CreateShortCut 21

!insertmacro CreateShortCut 22

!insertmacro CreateShortCut 23

!insertmacro CreateShortCut 24

!insertmacro CreateShortCut 25

!insertmacro CreateShortCut 26

!insertmacro CreateShortCut 27

!insertmacro CreateShortCut 28

!insertmacro CreateShortCut 29

!insertmacro CreateShortCut 30

CreateShortCut "$ME_TEMP2.lnk" $ME_TEMP3 $ME_TEMP4 $ME_TEMP5 "" "" "" $ME_TEMP7

the_end:

IfErrors +2

DetailPrint "$(DP_SHORTCUT) $ME_TEMP3"

FunctionEnd

;-----------------------------------------------------------------------------------------

Function DelINI

StrCmp $ME_TEMP4 "" +4

DetailPrint "$(DP_DEL_INI_ENTRY): $ME_TEMP2 [$ME_TEMP3] $ME_TEMP4"

DeleteINIStr $ME_TEMP2 $ME_TEMP3 $ME_TEMP4

Goto +3

DetailPrint "$(DP_DEL_INI_SECTION): $ME_TEMP2 [$ME_TEMP3]"

DeleteINISec $ME_TEMP2 $ME_TEMP3

FunctionEnd

; --------------------------------------

Function WriteINI

DetailPrint "$(DP_WRITE_INI): $ME_TEMP2 [$ME_TEMP3] $ME_TEMP4=$ME_TEMP5"

WriteINIStr $ME_TEMP2 $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

FunctionEnd

; --------------------------------------

Function WriteRegBin

DetailPrint '$(DP_WRITE_REG): $ME_TEMP2 "$ME_TEMP3" "$ME_TEMP4"=$ME_TEMP5'

#RegBin::writeRegBin $ME_TEMP2 $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

FunctionEnd

; --------------------------------------

Function WriteRegDWORD

DetailPrint '$(DP_WRITE_REG): $ME_TEMP2 "$ME_TEMP3" "$ME_TEMP4"=$ME_TEMP5'

StrCmp $ME_TEMP2 HKCR 0 +3

WriteRegDWORD HKCR $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKLM 0 +3

WriteRegDWORD HKLM $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKCU 0 +3

WriteRegDWORD HKCU $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKU 0 +3

WriteRegDWORD HKU $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKCC 0 +3

WriteRegDWORD HKCC $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKDD 0 +3

WriteRegDWORD HKDD $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKPD 0 +3

WriteRegDWORD HKPD $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

end:

FunctionEnd

; --------------------------------------

Function WriteRegStr

DetailPrint '$(DP_WRITE_REG): $ME_TEMP2 "$ME_TEMP3" "$ME_TEMP4"="$ME_TEMP5"'

StrCmp $ME_TEMP2 HKCR 0 +3

WriteRegStr HKCR $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKLM 0 +3

WriteRegStr HKLM $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKCU 0 +3

WriteRegStr HKCU $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKU 0 +3

WriteRegStr HKU $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKCC 0 +3

WriteRegStr HKCC $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKDD 0 +3

WriteRegStr HKDD $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

Goto end

StrCmp $ME_TEMP2 HKPD 0 +3

WriteRegStr HKPD $ME_TEMP3 $ME_TEMP4 $ME_TEMP5

end:

FunctionEnd

; --------------------------------------

Function DelRegKey

DetailPrint "$(DP_DEL_REG_KEY): $ME_TEMP2$ME_TEMP3"

StrCmp $ME_TEMP2 HKCR 0 +3

DeleteRegKey HKCR $ME_TEMP3

Goto end

StrCmp $ME_TEMP2 HKLM 0 +3

DeleteRegKey HKLM $ME_TEMP3

Goto end

StrCmp $ME_TEMP2 HKCU 0 +3

DeleteRegKey HKCU $ME_TEMP3

Goto end

StrCmp $ME_TEMP2 HKU 0 +3

DeleteRegKey HKU $ME_TEMP3

Goto end

StrCmp $ME_TEMP2 HKCC 0 +3

DeleteRegKey HKCC $ME_TEMP3

Goto end

StrCmp $ME_TEMP2 HKDD 0 +3

DeleteRegKey HKDD $ME_TEMP3

Goto end

StrCmp $ME_TEMP2 HKPD 0 +3

DeleteRegKey HKPD $ME_TEMP3

end:

FunctionEnd

; --------------------------------------

Function DelRegValue

DetailPrint "$(DP_DEL_REG_VALUE): $ME_TEMP2$ME_TEMP3 $ME_TEMP4"

StrCmp $ME_TEMP2 HKCR 0 +3

DeleteRegValue HKCR $ME_TEMP3 $ME_TEMP4

Goto end

StrCmp $ME_TEMP2 HKLM 0 +3

DeleteRegValue HKLM $ME_TEMP3 $ME_TEMP4

Goto end

StrCmp $ME_TEMP2 HKCU 0 +3

DeleteRegValue HKCU $ME_TEMP3 $ME_TEMP4

Goto end

StrCmp $ME_TEMP2 HKU 0 +3

DeleteRegValue HKU $ME_TEMP3 $ME_TEMP4

Goto end

StrCmp $ME_TEMP2 HKCC 0 +3

DeleteRegValue HKCC $ME_TEMP3 $ME_TEMP4

Goto end

StrCmp $ME_TEMP2 HKDD 0 +3

DeleteRegValue HKDD $ME_TEMP3 $ME_TEMP4

Goto end

StrCmp $ME_TEMP2 HKPD 0 +3

DeleteRegValue HKPD $ME_TEMP3 $ME_TEMP4

end:

FunctionEnd

; --------------------------------------

Function File

Push $R0

Push $R1

Push $R2

StrCmp $Local 1 local

DetailPrint "$(DP_DOWNLOADING) $ME_TEMP2 ..."

download:

!insertmacro dl $ME_TEMP2 ""

StrCpy $R9 $PLUGINSDIR

Goto +2

local:

StrCpy $R9 $EXEDIR

;如果指定了 MD5 则进行校验

StrCmp $ME_TEMP4 "" no_md5

md5dll::GetFileMD5 $R9$ME_TEMP2

Pop $R0

StrCmp $ME_TEMP4 $R0 +3

MessageBox MB_ICONEXCLAMATION|MB_YESNO "$(DP_MD5_FAILURE)" IDYES download

Call Exit

no_md5:

SetDetailsPrint none

SetOutPath $R9

SetDetailsPrint both

DetailPrint "$(DP_EXTRACT): $ME_TEMP2"

nsExec::Exec 'unrar x "$R9$ME_TEMP2" "$R9$ME_TEMP2.tmp"'

!insertmacro SetOutPath

IfFileExists $R9$ME_TEMP2.tmp*.* +3

MessageBox MB_ICONEXCLAMATION|MB_YESNO "$(DP_EXTRACT_FAILURE)" IDYES +2

Call Exit

FindFirst $R1 $R2 $R9$ME_TEMP2.tmp*.*

loop:

FindNext $R1 $R2

StrCmp $R2 "" loop_quit

StrCmp $R2 . loop

StrCmp $R2 .. loop

;如果目标参数为空,则使用 $OUTDIR 作为目标

StrCmp $ME_TEMP3 "" 0 +2

StrCpy $ME_TEMP3 $OUTDIR

DetailPrint "$R2 $(DP_COPY_TO) $ME_TEMP3"

SetDetailsPrint none

CreateDirectory $ME_TEMP3

ClearErrors

CopyFiles "$R9$ME_TEMP2.tmp$R2" $ME_TEMP3

IfErrors 0 copy_no_error

SetDetailsPrint both

DetailPrint "$(DP_COPY_ERROR)"

SetDetailsPrint none

SetRebootFlag true

Rename "$R9$ME_TEMP2.tmp$R2" "$R9$ME_TEMP2.tmp$R2.ludtmp"

SetFileAttributes "$R9$ME_TEMP2.tmp$R2.ludtmp" HIDDEN

ClearErrors

SetDetailsPrint none

CopyFiles "$R9$ME_TEMP2.tmp$R2.ludtmp" $ME_TEMP3

IfErrors 0 +3

MessageBox MB_OK|MB_ICONSTOP  "$(DP_COPY_FAIL)"

Call Exit

SetOutPath $ME_TEMP3

Rename /REBOOTOK $R2.ludtmp $R2

!insertmacro SetOutPath

copy_no_error:

SetDetailsPrint both

Goto loop

loop_quit:

FindClose $R1

Pop $R2

Pop $R1

Pop $R0

FunctionEnd

; --------------------------------------

Function SkipGroup

Push $R2

Push $R3

loop:

Call ReadFile

Pop $R2

StrCmp $R2 "" loop_quit

StrLen $R3 $R2

Push $R2

Call TrimLine

Pop $R2

Push $R2

Call GetMetaEntry

Pop $R2

StrCmp $ME_TEMP1 Group loop_quit

IntOp $1 $1 + $R3

Goto loop

loop_quit:

Pop $R3

Pop $R2

FunctionEnd

;-----------------------------------------------------------------------------------------

Function ReadFile

Push $R0

Push $R1

FileOpen $R1 $PLUGINSDIRinfo.txt r

FileSeek $R1 $1

FileRead $R1 $R0

FileClose $R1

Pop $R1

Exch $R0

FunctionEnd

;-----------------------------------------------------------------------------------------

Function TrimLine

Exch $R0

Push $R1

StrCpy $R1 $R0 1 -1  ;去除回车、换行

StrCmp $R1 $r 0 +3

StrCpy $R0 $R0 -1

Goto -3

StrCmp $R1 $n 0 +3

StrCpy $R0 $R0 -1

Goto -6

StrCpy $R1 $R0 1 -1  ;去除行尾空格

StrCmp $R1 " " 0 +3

StrCpy $R0 $R0 -1

Goto -3

StrCpy $R1 $R0 1     ;去除行首空格

StrCmp $R1 " " 0 +3

StrCpy $R0 $R0 "" 1

Goto -3

Pop $R1

Exch $R0

FunctionEnd

; --------------------------------------

Function WriteLog

SetDetailsPrint none

CreateDirectory "$PathPatchLog"

Call GetCurrentTime

Pop $R1

Rename $PLUGINSDIRlog.txt $PathPatchLog$R1.txt

FileOpen $R0 "$PathPatchLog$R1.txt" a    ;写入程序操作记录标题

FileSeek $R0 0 END

FileWrite $R0 "$r$n"

FileWrite $R0 "$r$n"

FileWrite $R0 "$r$n"

FileWrite $R0 "[$(STR_OP_LOG)]"

FileWrite $R0 "$r$n"

FileWrite $R0 "$r$n"

FileClose $R0

Push "$PathPatchLog$R1.txt"  ;当前的程序操作记录写入到文件

Call DumpLog

ReadINIStr $R0 "$PLUGINSDIRliveupdate.ini" "Field 8" "State"

StrCmp $R0 1 0 +2

ExecShell open "$PathPatchLog$R1.txt"

SetDetailsPrint both

FunctionEnd

; -----------------------------------------------------------------------------------------

Function GetCurrentTime

Push $R0

Push $R1

Push $R2

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .R0'

System::Call 'kernel32::GetLocalTime(i) i(R0)'

System::Call '*$R0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(.R0,,,,,,,)'

StrCpy $R1 $R0

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .R0'

System::Call 'kernel32::GetLocalTime(i) i(R0)'

System::Call '*$R0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(,.R0,,,,,,)'

StrCpy $R2 $R0 "" 1

StrCmp $R2 "" 0 +2

StrCpy $R0 "0$R0"

StrCpy $R1 "$R1-$R0"

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .R0'

System::Call 'kernel32::GetLocalTime(i) i(R0)'

System::Call '*$R0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(,,,.R0,,,,)'

StrCpy $R2 $R0 "" 1

StrCmp $R2 "" 0 +2

StrCpy $R0 "0$R0"

StrCpy $R1 "$R1-$R0"

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .R0'

System::Call 'kernel32::GetLocalTime(i) i(R0)'

System::Call '*$R0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(,,,,.R0,,,)'

StrCpy $R2 $R0 "" 1

StrCmp $R2 "" 0 +2

StrCpy $R0 "0$R0"

StrCpy $R1 "$R1-$R0h"

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .R0'

System::Call 'kernel32::GetLocalTime(i) i(R0)'

System::Call '*$R0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(,,,,,.R0,,)'

StrCpy $R2 $R0 "" 1

StrCmp $R2 "" 0 +2

StrCpy $R0 "0$R0"

StrCpy $R1 "$R1$R0m"

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .R0'

System::Call 'kernel32::GetLocalTime(i) i(R0)'

System::Call '*$R0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(,,,,,,.R0,)'

StrCpy $R2 $R0 "" 1

StrCmp $R2 "" 0 +2

StrCpy $R0 "0$R0"

StrCpy $R0 "$R1$R0s"

Pop $R2

Pop $R1

Exch $R0

FunctionEnd

; -----------------------------------------------------------------------------------------

Function GetParameters

Push $R0

Push $R1

Push $R2

Push $R3

Push $R4

StrCpy $R0 "$CMDLINE /"

StrCpy $R1 0

StrLen $R3 $R0

loop_pre:

StrCpy $R2 $R0 2 $R1

StrCmp $R2 ' /' loop_pre_quit

IntCmp $R1 $R3 the_end

IntOp $R1 $R1 + 1

Goto loop_pre

loop_pre_quit:

StrCpy $R0 $R0 "" $R1 ;$R0 为命令行参数

StrCpy $R1 0

StrLen $R3 $R0

loop:

StrCpy $R2 $R0 2 $R1

StrCmp $R2 ' /' loop_quit

IntCmp $R1 $R3 the_end

IntOp $R1 $R1 + 1

Goto loop

loop_quit:

StrCpy $R4 $R1

IntOp $R4 $R4 + 1

loop2:

StrCpy $R2 $R0 2 $R4

StrCmp $R2 ' /' loop2_quit

IntCmp $R4 $R3 the_end

IntOp $R4 $R4 + 1

Goto loop2

loop2_quit:

IntOp $R2 $R4 - $R1

StrCpy $R2 $R0 $R2 $R1

StrCpy $R2 $R2 "" 2

StrCpy $R1 $R4

;检测参数后面是否有空格

cut:

StrCpy $R4 $R2 "" -1

StrCmp $R4 " " 0 cut_end

StrCpy $R2 $R2 -1

Goto cut

cut_end:

;中间禁止给 $R1、$R2、$R3 赋新值

StrCmp $R2 '?' help

StrCmp $R2 help help

StrCmp $R2 fb2k fb2k

StrCmp $R2 storm storm

StrCmp $R2 local local

StrCpy $R4 $R2 8

StrCmp $R4 timeout timeout

StrCpy $R4 $R2 6

StrCmp $R4 proxy proxy

StrCpy $R4 $R2 8

StrCmp $R4 noproxy no_proxy

StrCpy $R4 $R2 9

StrCmp $R4 writelog writelog

StrCpy $R4 $R2 8

StrCmp $R4 viewlog viewlog

StrCpy $R4 $R2 5

StrCmp $R4 auto auto

StrCpy $R4 $R2 4

StrCmp $R4 'url:' url

StrCpy $R4 $R2 3

StrCmp $R4 'es:' end_start

StrCmp $R2 nt no_temp

Goto cout

fb2k:

WriteRegStr ${STR_REGKEY} UpdateType 1

Goto cout

storm:

WriteRegStr ${STR_REGKEY} UpdateType 0

Goto cout

local:

StrCpy $Local 1

Goto cout

timeout:

StrCpy $R4 $R2 "" 9

IntCmp $R4 0 0 0 +2 ;检测值要大于 0,否则置为默认

StrCpy $R4 30000

StrCmp $R4 "" 0 +2 ;如果值不存在则置为默认

StrCpy $R4 30000

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 2" "State"  "$R4"

Goto cout

proxy:

StrCpy $R4 $R2 "" 7

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 4" "State" 1

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 6" "State" "$R4"

Goto cout

no_proxy:

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 4" "State" 0

Goto cout

writelog:

StrCpy $R4 $R2 "" 10

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 9" "State" "$R4"

StrCmp $R2 '/writelog' 0 +2

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 9" "State" 1

Goto cout

viewlog:

StrCpy $R4 $R2 "" 9

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 8" "State" "$R4"

StrCmp $R2 '/viewlog' 0 +2

WriteINIStr "$PLUGINSDIRliveupdate.ini" "Field 8" "State" 1

Goto cout

auto:

StrCpy $AUTO 1

Goto cout

url:

StrCpy $URL $R2 "" 4

Goto cout

end_start:

StrCpy $R4 $R2 "" 3

WriteINIStr "$PLUGINSDIRsetting.ini" "setting" "EndStart" $R4

Goto cout

help:

MessageBox MB_OK|MB_ICONINFORMATION '$(MB_HELP)'

Quit

no_temp:

WriteINIStr "$PLUGINSDIRsetting.ini" "setting" NoTemp 1

Goto cout

cout:

StrCpy $R4 $R1

IntOp $R4 $R4 + 1

Goto loop2

the_end:

Pop $R4

Pop $R3

Pop $R2

Pop $R1

Exch $R0

FunctionEnd

; -----------------------------------------------------------------------------------------

Function DumpLog

Exch $R5

Push $R0

Push $R1

Push $R2

Push $R3

Push $R4

Push $R6

FindWindow $R0 "#32770" "" $HWNDPARENT

GetDlgItem $R0 $R0 1016

StrCmp $R0 0 exit

FileOpen $R5 $R5 "a"

FileSeek $R5 0 END

StrCmp $R5 "" exit

SendMessage $R0 0x1004 0 0 $R6

System::Alloc ${NSIS_MAX_STRLEN}

Pop $R3

StrCpy $R2 0

System::Call "*(i, i, i, i, i, i, i, i, i) i

(0, 0, 0, 0, 0, R3, ${NSIS_MAX_STRLEN}) .R1"

loop: StrCmp $R2 $R6 done

System::Call "User32::SendMessageA(i, i, i, i) i

($R0, 0x102D, $R2, R1)"

System::Call "*$R3(&t${NSIS_MAX_STRLEN} .R4)"

FileWrite $R5 "$R4"

FileWriteByte $R5 13

FileWriteByte $R5 10

IntOp $R2 $R2 + 1

Goto loop

done:

FileClose $R5

System::Free $R1

System::Free $R3

exit:

Pop $R6

Pop $R4

Pop $R3

Pop $R2

Pop $R1

Pop $R0

Pop $R5

FunctionEnd

;----------------------------------------------------------------------

Function GetWinVer

Push $R0

Push $R1

ReadRegStr $R0 HKLM "SOFTWAREMicrosoftWindows NTCurrentVersion" CurrentVersion

StrCmp $R0 "" 0 os_winnt

StrCpy $R0 '9X'

ReadRegStr $R1 HKLM "SOFTWAREMicrosoftWindowsCurrentVersion" ProductName

Goto os_done

os_winnt:

StrCpy $R0 'NT'

ReadRegStr $R1 HKLM "SOFTWAREMicrosoftWindows NTCurrentVersion" ProductName

os_done:

Exch $R1

Exch

Exch $R0

FunctionEnd

;----------------------------------------------------------------------------------------------------

Function ChangeVar     ;把 $........$ 之间代表的变量转换为实际值

Exch $R0

Push $R1

Push $R2

Push $R3

Push $R4

StrCpy $R1 0

StrLen $R3 $R0

loop:

StrCpy $R4 $R0 2 $R1

StrCmp $R4 $$$$ jump

StrCpy $R4 $R0 1 $R1

StrCmp $R4 $$ loop_quit

IntCmp $R1 $R3 no_var 0 no_var

IntOp $R1 $R1 + 1

Goto loop

jump:

StrCpy $R4 $R0 $R1

IntOp $R1 $R1 + 1

StrCpy $R0 $R0 "" $R1

StrCpy $R0 $R4$R0

StrLen $R3 $R0

Goto loop

loop_quit:

StrCpy $R2 $R1

IntOp $R2 $R2 + 1

loop2:

StrCpy $R4 $R0 2 $R2

StrCmp $R4 $$$$ jump2

StrCpy $R4 $R0 1 $R2

StrCmp $R4 $$ loop2_quit

IntCmp $R2 $R3 no_var 0 no_var

IntOp $R2 $R2 + 1

Goto loop2

jump2:

StrCpy $R4 $R0 $R2

IntOp $R2 $R2 + 1

StrCpy $R0 $R0 "" $R2

StrCpy $R0 $R4$R0

StrLen $R3 $R0

Goto loop2

loop2_quit:

IntOp $R4 $R2 - $R1

StrCpy $R4 $R0 $R4 $R1

StrCpy $R4 $R4 "" 1

StrCmp $R4 InstallDir 0 +3

StrCpy $R4 $Path

Goto change_var

StrCmp $R4 PLUGINSDIR 0 +3

StrCpy $R4 $PLUGINSDIR

Goto change_var

StrCmp $R4 PROGRAMFILES 0 +3

StrCpy $R4 $PROGRAMFILES

Goto change_var

StrCmp $R4 COMMONFILES 0 +3

StrCpy $R4 $COMMONFILES

Goto change_var

StrCmp $R4 DESKTOP 0 +3

StrCpy $R4 $DESKTOP

Goto change_var

StrCmp $R4 WINDIR 0 +3

StrCpy $R4 $WINDIR

Goto change_var

StrCmp $R4 SYSDIR 0 +3

StrCpy $R4 $SYSDIR

Goto change_var

StrCmp $R4 TEMP 0 +3

StrCpy $R4 $TEMP

Goto change_var

StrCmp $R4 EXEDIR 0 +3

StrCpy $R4 $EXEDIR

Goto change_var

StrCmp $R4 STARTMENU 0 +3

StrCpy $R4 $STARTMENU

Goto change_var

StrCmp $R4 SMPROGRAMS 0 +3

StrCpy $R4 $SMPROGRAMS

Goto change_var

StrCmp $R4 SMSTARTUP 0 +3

StrCpy $R4 $SMSTARTUP

Goto change_var

StrCmp $R4 QUICKLAUNCH 0 +3

StrCpy $R4 "$QUICKLAUNCH"

Goto change_var

StrCmp $R4 DOCUMENTS 0 +3

StrCpy $R4 "$DOCUMENTS"

Goto change_var

StrCmp $R4 SENDTO 0 +3

StrCpy $R4 "$SENDTO"

Goto change_var

StrCmp $R4 RECENT 0 +3

StrCpy $R4 "$RECENT"

Goto change_var

StrCmp $R4 RECENT 0 +3

StrCpy $R4 "$RECENT"

Goto change_var

StrCmp $R4 FAVORITES 0 +3

StrCpy $R4 "$FAVORITES"

Goto change_var

StrCmp $R4 MUSIC 0 +3

StrCpy $R4 "$MUSIC"

Goto change_var

StrCmp $R4 PICTURES 0 +3

StrCpy $R4 "$PICTURES"

Goto change_var

StrCmp $R4 VIDEOS 0 +3

StrCpy $R4 "$VIDEOS"

Goto change_var

StrCmp $R4 NETHOOD 0 +3

StrCpy $R4 "$NETHOOD"

Goto change_var

StrCmp $R4 FONTS 0 +3

StrCpy $R4 "$FONTS"

Goto change_var

StrCmp $R4 TEMPLATES 0 +3

StrCpy $R4 "$TEMPLATES"

Goto change_var

StrCmp $R4 APPDATA 0 +3

StrCpy $R4 "$APPDATA"

Goto change_var

StrCmp $R4 PRINTHOOD 0 +3

StrCpy $R4 "$PRINTHOOD"

Goto change_var

StrCmp $R4 INTERNET_CACHE 0 +3

StrCpy $R4 "$INTERNET_CACHE"

Goto change_var

StrCmp $R4 COOKIES 0 +3

StrCpy $R4 "$COOKIES"

Goto change_var

StrCmp $R4 HISTORY 0 +3

StrCpy $R4 "$HISTORY"

Goto change_var

StrCmp $R4 PROFILE 0 +3

StrCpy $R4 "$PROFILE"

Goto change_var

StrCmp $R4 ADMINTOOLS 0 +3

StrCpy $R4 "$ADMINTOOLS"

Goto change_var

StrCmp $R4 RESOURCES 0 +3

StrCpy $R4 "$RESOURCES"

Goto change_var

StrCmp $R4 RESOURCES_LOCALIZED 0 +3

StrCpy $R4 "$RESOURCES_LOCALIZED"

Goto change_var

StrCmp $R4 CDBURN_AREA 0 +3

StrCpy $R4 "$CDBURN_AREA"

Goto change_var

StrCmp $R4 HWNDPARENT 0 unknown

StrCpy $R4 "$HWNDPARENT"

Goto change_var

unknown:

StrCpy $R1 $R2

IntOp $R1 $R1 + 1

Goto loop

change_var:

StrCpy $R3 $R0 $R1

StrCpy $R3 "$R3$R4"

IntOp $R2 $R2 + 1

StrCpy $R4 $R0 "" $R2

StrCpy $R0 "$R3$R4"

StrLen $R3 $R0

Goto loop

no_var:

Pop $R4

Pop $R3

Pop $R2

Pop $R1

Exch $R0

FunctionEnd

;-------------------------------------------------------------------------------

Function Exit

Call Exit2

Quit

FunctionEnd

Function Exit2

SetDetailsPrint none

DeleteRegValue ${STR_REGKEY} ErrorFiles

ReadRegDWORD $R0 HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyEnable_Backup

StrCmp $R0 "" +2

WriteRegDWORD HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyEnable "$R0"

ReadRegStr $R0 HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer_Backup

StrCmp $R0 "" +2

WriteRegStr HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer "$R0"

ReadRegStr $R0 HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer_NONE

StrCmp $R0 1 0 +2

DeleteRegValue HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer

DeleteRegValue HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer_Backup

DeleteRegValue HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyEnable_Backup

DeleteRegValue HKCU "SoftwareMicrosoftWindowsCurrentVersionInternet Settings" ProxyServer_NONE

SetDetailsPrint both

IfRebootFlag 0 no_reboot

MessageBox MB_YESNO|MB_ICONINFORMATION "$(STR_REBOOT)" IDNO no_reboot

ReadINIStr $R0 "$PLUGINSDIRsetting.ini" "setting" NoTemp

StrCmp $R0 1 0 no_temp

System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'

Pop $R0

Delete /REBOOTOK $R0 ;删除自身

no_temp:

Reboot

Quit

no_reboot:

ReadINIStr $R0 "$PLUGINSDIRsetting.ini" "setting" "EndStart"

StrCmp $R0 "" +3

Exec "$Path$R0"

Sleep 500

FunctionEnd

; --------------------------------------

Function RefreshShellIcons

System::Call 'shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)'

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

转载请注明:永恒心锁-分享互联网 » 蓝色网际liveupdate软件更新脚本

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