脚本:ACDSee 3.1 SR1 美化版

优质
小牛编辑
137浏览
2023-12-01
引用acdc31sr1.nsi的内容:

;************************************************************
;脚本编写: 蓝色网际

;某些使用了 LogSet 指令的脚本需要使用特别版的 makensis.exe 才能通过编译
;地址: http://nsis.sourceforge.net/download/specialbuilds/

; 定义 DEBUG 时安装完成将弹出安装信息
;!define DEBUG
;************************************************************

!ifdef NSIS_MOD_CHS
Name                 "ACDSee 3.1 SR1 美化版 build ${__MONTH__}${__DAY__}" 
!else
Name                 "ACDSee 3.1 SR1 美化版" 
!endif
OutFile              "acdc31sr1.exe"
SetCompressor        lzma                   
SpaceTexts           none                   
ShowInstDetails      show                   
BrandingText         "$(^NameDA)安装程序 ${__DATE__} "
UninstallCaption     "$(^NameDA)卸载程序"
ShowUninstDetails    show
InstallDir           "$PROGRAMFILES\ACDSee"
InstallDirRegKey     HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" InstallDir

ReserveFile          ".\resource\acdsee.ini"
ReserveFile          ".\resource\gaydata.ini"
ReserveFile          "${NSISDIR}\Plugins\System.dll"

!include             "MUI.nsh"
!include             "StrFunc.nsh"
!include             "Sections.nsh"

	!define MUI_ICON ".\resource\ico-inst.ico"
  !define MUI_UNICON ".\resource\ico-uninst.ico"
  !define MUI_WELCOMEFINISHPAGE_BITMAP ".\resource\Winz.bmp"
  !define MUI_COMPONENTSPAGE_CHECKBITMAP ".\resource\acdsee.bmp"
  !define MUI_HEADERIMAGE
  !define MUI_HEADERIMAGE_BITMAP ".\resource\Header.bmp"
  !define MUI_WELCOMEPAGE_TEXT "ACDSee 是目前最流行的数字图象处理软件,它能广泛应用于图片的获取、管理、浏览、优化甚至和他人的分享!使用 ACDSee,你可以从数码相机和扫描仪高效获取图片,并进行便捷的查找、组织和预览。超过 50 种常用多媒体格式被一网打尽!作为最重量级看图软件,它能快速、高质量显示您的图片,再配以内置的音频播放器,我们就可以享用它播放出来的精彩幻灯片了。ACDSee 还能处理如 Mpeg 之类常用的视频文件。此外 ACDSee 是您最得心应手的图片编辑工具,轻松处理数码影像,拥有的功能像去除红眼、剪切图像、锐化、浮雕特效、曝光调整、旋转、镜像等等,还能进行批量处理。"

  !define MUI_PAGE_CUSTOMFUNCTION_SHOW ChageFONT
  !insertmacro MUI_PAGE_WELCOME
  !insertmacro MUI_PAGE_LICENSE ".\resource\License.rtf"
  Page custom SetCustom
	!define MUI_PAGE_CUSTOMFUNCTION_PRE ComponentPre
	!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentShow
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
	!define MUI_PAGE_HEADER_TEXT "文件关联"
	!define MUI_PAGE_HEADER_SUBTEXT "选择需要关联的文件格式"
	!define MUI_PAGE_CUSTOMFUNCTION_PRE AsscoiationPre
	!define MUI_PAGE_CUSTOMFUNCTION_SHOW AsscoiationShow
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_INSTFILES
  !define MUI_PAGE_CUSTOMFUNCTION_SHOW ChageFONT
  !insertmacro MUI_PAGE_FINISH

  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  
  !insertmacro MUI_LANGUAGE "SimpChinese"
  ChangeUI IDD_SELCOM ".\resource\acdsee_nodesc.exe"

;声明字串操作指令
${StrCase} ;小写转大写

!macro ASSOC EXT ICON
	Push $0
	Push $1
	
	${StrCase} $0 '${EXT}' "U"
	
	ReadRegStr $1 HKCR ".${EXT}" ""
	${If} $1 != "ACDSee.$0"
		WriteRegStr HKCR ".${EXT}\UndoClass" "" $1
		WriteRegStr HKCR "ACDSee.File" "${EXT}" ""
	${ElseIf} $1 != ""
		DeleteRegValue HKCR "ACDSee.$0\shell\open\DropTarget" Clsid
		DeleteRegValue HKCR "ACDSee.$0\shell\open" MuiVerb
	${EndIf}
	
  DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.${EXT}"
  WriteRegStr HKCR ".${EXT}" "" "ACDSee.$0"
  WriteRegStr HKCR "ACDSee.$0" "" "ACDSee $0 图像"
  WriteRegStr HKCR "ACDSee.$0\DefaultIcon" "" "${ICON}"
  WriteRegStr HKCR "ACDSee.$0\shell" "" Open
  WriteRegStr HKCR "ACDSee.$0\shell\Open" "" "用 ACDSee 打开"  
  WriteRegStr HKCR "ACDSee.$0\shell\Open\Command" "" '"$INSTDIR\ACDSee.exe" /dde'
  WriteRegStr HKCR "ACDSee.$0\shell\Open\DDEExec" "" '[open("%1")]'
  WriteRegStr HKCR "ACDSee.$0\shell\Open\DDEExec\Application" "" ACDSee
  WriteRegStr HKCR "ACDSee.$0\shell\Open\DDEExec\Topic" "" System
  WriteRegStr HKCR "ACDSee.$0\shell\ACDPrint" "" "用 ACDSee 打印"
  WriteRegStr HKCR "ACDSee.$0\shell\ACDPrint\Command" "" '"$INSTDIR\ACDSee.exe" /p "%1"'
	
	ReadRegStr $1 HKCR "CLSID\{68f32140-2ca3-11d0-acc1-444553540000}" ""
	StrCmp $1 "" +2
  WriteRegStr HKCR "ACDSee.$0\shellex\ContextMenuHandlers\PicaView" "" "{68f32140-2ca3-11d0-acc1-444553540000}"
  
	DetailPrint "关联文件: .$0"
	
	Pop $1
	Pop $0
!macroend	

!macro ASSOC_TYPE EXT TYPE
	Push $0
	
	ReadRegStr $0 HKCR ".${EXT}" ""
	StrCmp $0 "ACDSee.${TYPE}" +3
	WriteRegStr HKCR ".${EXT}\UndoClass" "" $0
	WriteRegStr HKCR "ACDSee.FILE" "${EXT}" ""
	
  DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.${EXT}"
  WriteRegStr HKCR ".${EXT}" "" "ACDSee.${TYPE}"
  
	Pop $0	
!macroend		

	;压缩档右键命令
!macro ASSOC_ARCHIVE EXT ARCHIVE_PLUGINS
	Push $0
	
	ReadRegStr $0 HKCR ".${EXT}" ""
	${If} $0 == "" ;如果压缩文件没有关联则进行关联
		${StrCase} $0 '${EXT}' "U"
		!insertmacro ASSOC "${EXT}" "${ARCHIVE_PLUGINS}"
		WriteRegStr HKCR "ACDSee.${EXT}" "" "ACDSee 压缩文档($0)"
		DeleteRegKey HKCR "ACDSee.${EXT}\shell"
	${Else}
		ReadRegStr $0 HKCR ".${EXT}" ""
		WriteRegStr HKCR "$0\Shell\ACDSeeView" "" "用 ACDSee 察看"
		WriteRegStr HKCR "$0\Shell\ACDSeeView\command" "" '"$INSTDIR\ACDSee.exe" "%1"'
		WriteRegStr HKCR "ACDSee.File\Archive" "$0\Shell\ACDSeeView" ""
	${EndIf}
	
	Pop $0
!macroend

!macro SelectIfSet SECTION
  Push $0
  Push $1
    SectionGetFlags "${SECTION}" $0
    IntOp $1 $0 & ${SF_SELECTED}
		StrCmp $1 ${SF_SELECTED} +5 
		IntOp $0 $0 & ${SECTION_OFF}
    SectionSetFlags "${${SECTION}}" $0
		SectionSetText "${${SECTION}}" ""
		Goto +3
		IntOp $0 $0 | ${SF_SELECTED}
    SectionSetFlags "${${SECTION}}" $0
  Pop $1
  Pop $0
!macroend

Section "主程序及标准插件" main
  SectionIn RO
	;系统文件
	SetOverwrite off
	SetOutPath $SYSDIR
	File ".\include\Roboex32.dll"
	File ".\include\msvcr71.dll"
	SetOverwrite on
  Delete "$INSTDIR\install.log"
  LogSet on
	SetOutPath $INSTDIR
	File /r ".\include\main\*.*"
	SetOutPath "$INSTDIR\PlugIns"
	StrCpy $0 "$INSTDIR\PlugIns\IDE_ACDStd.apl"
	ClearErrors
	Delete $0
	${If} ${Errors}
		GetTempFileName $1
		StrCpy $0 $1
	${EndIf}
	File "/oname=$0" ".\include\plugins\IDE_ACDStd.apl"
	${IfThen} $0 == $1 ${|} Rename /REBOOTOK $0 "$INSTDIR\PlugIns\IDE_ACDStd.apl" ${|}
	File ".\include\plugins\IDE_ACDStd.chm"
	
  WriteRegStr HKLM "SOFTWARE\ACD Systems\PlugInsV1" PIFolder "$INSTDIR\PlugIns"
	WriteRegBin HKLM "SOFTWARE\ACD Systems\ACDInTouch" "InTouchSettings" 01013d00000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050000000
  WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDSee" "" 3.1.1
	WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDSeeCS" "" 3.1.1
  WriteRegBin HKLM "SOFTWARE\ACD Systems\ACDSeeCS" InTouchSettings 01535c4300000000
  WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDSeeCS" SourceID 001
  WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDSeeCS" InstallationDate HBNHFNEGGHCKKJDN091A4FB9
  WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDSeeCS" InTouchConfigRemind CJPJNNEGGHCKKBBI08599FBA
  WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ACDSee.exe" "" "$INSTDIR\ACDSee.exe"
  WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ACDSee.exe" Path $INSTDIR
  WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\PELite.exe" "" "$INSTDIR\PELite.exe"
  WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\PELite.exe" Path $INSTDIR

  WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\Help" ACDSee.hlp $INSTDIR
	
  WriteRegDWORD HKCU "Software\ACD Systems\ACDSee\Tip" StartUp 1
	WriteRegBin HKCU "Software\ACD Systems\ACDSeeCS" RememberDir 01
	
	DeleteRegValue HKCR "SystemFileAssociations\image\ShellEx\ContextMenuHandlers\ShellImagePreview" ""
	
	;注册信息
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 3" "State"
  WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDSeeCS" LicenseNumber $0
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 7" "State"
	WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDInTouch" UserName $0
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 9" "State"
	WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDInTouch" CompanyName $0
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 11" "State"
	WriteRegStr HKLM "SOFTWARE\ACD Systems\ACDInTouch" UserEMail $0
SectionEnd	

Section "ACD 图像编辑器"
	File "/oname=$INSTDIR\PELite.exe" ".\include\PELite.exe"
SectionEnd	

Section PicaView
	SetOverwrite try
  File "/oname=$INSTDIR\PicaView.dll" ".\include\PicaView.dll"
	SetOverwrite on
	
  WriteRegBin HKCU "Software\ACD Systems\PicaView" CheckAllExtensions 00000000
  WriteRegBin HKCU "Software\ACD Systems\PicaView" PlaySounds 00
  WriteRegBin HKCU "Software\ACD Systems\PicaView" ShowFileSize 01000000
  WriteRegStr HKLM "Software\ACD Systems\PicaView" LicenseNumber 078723450172918441
	
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 7" "State"
  WriteRegStr HKLM "Software\ACD Systems\PicaView" UserName $0
	
  WriteRegStr HKLM "Software\ACD Systems\PicaView" PIFolder "$INSTDIR\PlugIns"
  WriteRegStr HKCR "CLSID\{68f32140-2ca3-11d0-acc1-444553540000}" "" "PicaView 外壳扩展"
  WriteRegStr HKCR "CLSID\{68f32140-2ca3-11d0-acc1-444553540000}\InProcServer32" "" "$INSTDIR\picaview.dll"
  WriteRegStr HKCR "CLSID\{68f32140-2ca3-11d0-acc1-444553540000}\InProcServer32" ThreadingModel Apartment
  WriteRegStr HKCR "PicaViewImage\Shell\Open\Command" "" 'rundll32 "$INSTDIR\picaview.dll,showimage %1"'
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" "{68f32140-2ca3-11d0-acc1-444553540000}" "PicaView"
SectionEnd

SubSection /e "扩展图形格式支持插件"
	
Section "图标和光标格式" ico
	File ".\include\plugins\ID_ICO.apl"
SectionEnd

Section "PhotoShop 图像" psd
	File ".\include\plugins\IDE_PSD.apl"
SectionEnd

Section "Paint Shop Pro 图像" psp
	File ".\include\plugins\ID_PSP.apl"
SectionEnd

Section "SGI 图像" sgi
	File ".\include\plugins\IDE_SGI.apl"
SectionEnd

Section "Kodak Photo 图像" pcd
	File ".\include\plugins\ID_PhotoCD.apl"
SectionEnd

Section "JPEG 2000" jp2
	File ".\include\plugins\IDE_JP2.apl"
SectionEnd

Section "数码相机 RAW 插件" raw
	File ".\include\plugins\ID_DCRaw.apl"
SectionEnd
	
Section
SectionEnd
	
Section "ICN 图标支持插件" icn
	File ".\include\plugins\ID_ICN.apl"
SectionEnd
	
SubSectionEnd

SubSection /e "功能扩展插件"
	
Section "无损 JPEG 旋转"
	File ".\include\plugins\CX_JPEGTrans.apl"
SectionEnd

Section "HTML 像册生成器" cx_html
	File ".\include\plugins\CX_HTML.apl"
	File ".\include\plugins\CX_HTML.chm"
	File ".\include\plugins\acdcp.dll"
SectionEnd

Section "图册实用工具" cx_csheet
	File ".\include\plugins\CX_ContactSheet.apl"
	File ".\include\plugins\CX_ContactSheet.chm"
SectionEnd

Section "调整层次"
	File ".\include\plugins\CX_AdjustLevels.apl"
SectionEnd

SubSectionEnd

SubSection /e "压缩文档支持插件"
	
Section ZIP zip
	File ".\include\plugins\AM_ZIP.apl"
SectionEnd
		
Section /o LHA lha
	File ".\include\plugins\AM_LHA.apl"
SectionEnd
		
Section /o RAR rar
	File ".\include\plugins\AM_RAR.apl"
SectionEnd
		
SubSectionEnd
	
Section "-post" post
	;桌面快捷方式
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 13" "State"
  ${If} $0 == 1
		CreateShortCut "$DESKTOP\ACDSee 3.1.lnk" "$INSTDIR\ACDSee.exe"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" Desktop 1
	${EndIf}
  
	;开始菜单
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 14" "State"
  ${If} $0 == 1
		CreateDirectory "$SMPROGRAMS\ACDSee"
		CreateShortCut "$SMPROGRAMS\ACDSee\ACDSee 3.1.lnk" "$INSTDIR\ACDSee.exe"
		CreateShortCut "$SMPROGRAMS\ACDSee\卸载.lnk" "$INSTDIR\uninstall.exe"
		CreateShortCut "$SMPROGRAMS\ACDSee\帮助文档.lnk" "$INSTDIR\ACDSee.hlp"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" StartMenu 1
	${EndIf}
  
	;快速启动
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 15" "State"
  ${If} $0 == 1
		CreateShortCut "$QUICKLAUNCH\ACDSee 3.1.lnk" "$INSTDIR\ACDSee.exe"
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" QuickLaunch 1
  ${EndIf}
	
	WriteUninstaller "$INSTDIR\uninstall.exe"
  LogSet off
	
	;目录右键菜单
  ReadINIStr $0 "$PLUGINSDIR\ACDSee.ini" "Field 20" "State"
  ${If} $0 == 1
		WriteRegStr HKCR "Directory\shell\ACDBrowse" "" "用 ACDSee 浏览"
		WriteRegStr HKCR "Directory\shell\ACDBrowse\command" "" '"$INSTDIR\ACDSee.exe" "%1"'
		WriteRegStr HKCR "Drive\shell\ACDBrowse" "" "用 ACDSee 浏览"
		WriteRegStr HKCR "Drive\shell\ACDBrowse\command" "" '"$INSTDIR\ACDSee.exe" "%1"'
		WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" ContextMenu 1
	${EndIf}
	
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" "DisplayName" "$(^NameDA)"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" UninstallString "$INSTDIR\uninstall.exe"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" DisplayIcon "$INSTDIR\ACDSee.exe"
	${StrCase} $0 '$INSTDIR' "U"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" "InstallDir" $0 
	
SectionEnd

Section "Association" association
SectionEnd

Section "Windows 和 OS/2 位图(bmp,dib,rle,wbmp)"
	!insertmacro ASSOC bmp "$INSTDIR\PlugIns\IDE_ACDStd.apl,1"
	!insertmacro ASSOC dib "$INSTDIR\PlugIns\IDE_ACDStd.apl,1"
	!insertmacro ASSOC rle "$INSTDIR\PlugIns\IDE_ACDStd.apl,1"
	!insertmacro ASSOC wbmp "$INSTDIR\PlugIns\IDE_ACDStd.apl,11"
SectionEnd

Section "增强图元文件格式(emf)"
	!insertmacro ASSOC emf "$INSTDIR\PlugIns\IDE_ACDStd.apl,2"
SectionEnd

Section "图形交换格式(gif)"
	!insertmacro ASSOC gif "$INSTDIR\PlugIns\IDE_ACDStd.apl,3"
SectionEnd

Section "标准 JPEG(jpg,jpeg,jpe,jif,jfif)"
	!insertmacro ASSOC jpg "$INSTDIR\PlugIns\IDE_ACDStd.apl,4"
	!insertmacro ASSOC jpeg "$INSTDIR\PlugIns\IDE_ACDStd.apl,4"
	!insertmacro ASSOC jpe "$INSTDIR\PlugIns\IDE_ACDStd.apl,4"
	!insertmacro ASSOC jif "$INSTDIR\PlugIns\IDE_ACDStd.apl,4"
	!insertmacro ASSOC jfif "$INSTDIR\PlugIns\IDE_ACDStd.apl,4"
SectionEnd

Section "ZSoft 出版画笔(pcx,dcx)"
	!insertmacro ASSOC pcx "$INSTDIR\PlugIns\IDE_ACDStd.apl,5"
	!insertmacro ASSOC dcx "$INSTDIR\PlugIns\IDE_ACDStd.apl,5"
SectionEnd

Section "便携网络图形(png)"
	!insertmacro ASSOC png "$INSTDIR\PlugIns\IDE_ACDStd.apl,6"
SectionEnd

Section "Targa TGA(tga)"
	!insertmacro ASSOC tga "$INSTDIR\PlugIns\IDE_ACDStd.apl,7"
SectionEnd

Section "Tag 图片文件格式(tif,tiff,xif)"
	!insertmacro ASSOC tif "$INSTDIR\PlugIns\IDE_ACDStd.apl,8"
	!insertmacro ASSOC tiff "$INSTDIR\PlugIns\IDE_ACDStd.apl,8"
	!insertmacro ASSOC xif "$INSTDIR\PlugIns\IDE_ACDStd.apl,8"
SectionEnd

Section "Windows 3.x 图元文件格式(wmf)"
	!insertmacro ASSOC wmf "$INSTDIR\PlugIns\IDE_ACDStd.apl,9"
SectionEnd

Section "Pegasus PIC 格式(pic)"
  SectionIn 1 2
	!insertmacro ASSOC pic "$INSTDIR\PlugIns\IDE_ACDStd.apl,10"
SectionEnd

Section "图标格式(ico,cur,ani)" ${ico}
	!insertmacro ASSOC ico "%1"
	!insertmacro ASSOC cur "%1"
	!insertmacro ASSOC ani "%1"
SectionEnd

Section "PhotoShop 图像格式(psd)" ${psd}
	!insertmacro ASSOC psd "$INSTDIR\PlugIns\IDE_PSD.apl,0"
SectionEnd

Section "Paint Shop Pro 图像格式(pspimage,psp,pspframe,pspshape,psptube,tub)" ${psp}
	!insertmacro ASSOC psp "$INSTDIR\PlugIns\ID_PSP.apl,0"
	!insertmacro ASSOC_TYPE pspimage PSP 
	!insertmacro ASSOC_TYPE pspframe PSP
	!insertmacro ASSOC_TYPE pspshape PSP
	!insertmacro ASSOC_TYPE psptube PSP
	!insertmacro ASSOC_TYPE tub PSP
SectionEnd

Section "SGI 图像格式(sgi)" ${sgi}
	!insertmacro ASSOC sgi "$INSTDIR\PlugIns\IDE_SGI.apl,0"
SectionEnd

Section "Kodak Photo 图像格式(pcd)" ${pcd}
	!insertmacro ASSOC pcd "$INSTDIR\PlugIns\ID_PhotoCD.apl,0"
SectionEnd

Section "JPEG 2000(jp2)" ${jp2}
	!insertmacro ASSOC jp2 "$INSTDIR\PlugIns\IDE_JP2.apl,0"
	!insertmacro ASSOC jpc "$INSTDIR\PlugIns\IDE_JP2.apl,0"
SectionEnd

Section "数码相机 RAW 格式图像" ${raw}
	!insertmacro ASSOC raw "$INSTDIR\PlugIns\ID_DCRaw.apl,0"
	!insertmacro ASSOC cr2 "$INSTDIR\PlugIns\ID_DCRaw.apl,1"
	!insertmacro ASSOC crw "$INSTDIR\PlugIns\ID_DCRaw.apl,2"
	!insertmacro ASSOC dcr "$INSTDIR\PlugIns\ID_DCRaw.apl,3"
	!insertmacro ASSOC mrw "$INSTDIR\PlugIns\ID_DCRaw.apl,4"
	!insertmacro ASSOC nef "$INSTDIR\PlugIns\ID_DCRaw.apl,5"
	!insertmacro ASSOC orf "$INSTDIR\PlugIns\ID_DCRaw.apl,6"
	!insertmacro ASSOC pef "$INSTDIR\PlugIns\ID_DCRaw.apl,7"
	!insertmacro ASSOC raf "$INSTDIR\PlugIns\ID_DCRaw.apl,8"
	!insertmacro ASSOC tiff "$INSTDIR\PlugIns\ID_DCRaw.apl,9"
	!insertmacro ASSOC x3f "$INSTDIR\PlugIns\ID_DCRaw.apl,10"
SectionEnd

Section "ICN 图标(icn)" ${icn}
	!insertmacro ASSOC icn "$INSTDIR\PlugIns\ID_ICN.apl,0"
SectionEnd

Section "ZIP (右键菜单)" ${zip}
	!insertmacro ASSOC_ARCHIVE zip "$INSTDIR\PlugIns\AM_ZIP.apl"
SectionEnd
		
Section "LHA (右键菜单)" ${lha}
	!insertmacro ASSOC_ARCHIVE lha "$INSTDIR\PlugIns\AM_LHA.apl"
SectionEnd
		
Section "RAR (右键菜单)" ${rar}
	!insertmacro ASSOC_ARCHIVE rar "$INSTDIR\PlugIns\AM_RAR.apl"
SectionEnd
		
Section "End" end
SectionEnd

!ifdef DEBUG
Section
	Push "$PLUGINSDIR\debug.txt"
	Call DumpLog
	ExecShell open "$PLUGINSDIR\debug.txt" "" SW_SHOWMAXIMIZED
	Sleep 1000
SectionEnd

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
!endif

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

Function .onInit
  InitPluginsDir
	File "/oname=$PLUGINSDIR\acdsee.ini" ".\resource\acdsee.ini"
	File "/oname=$PLUGINSDIR\gaydata.ini" ".\resource\gaydata.ini"
	
	System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"
  WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 7" "State" $0
	
	ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" "InstallDir"
	${If} $0 != ""
		ReadRegStr $0 HKLM "SOFTWARE\ACD Systems\ACDSeeCS" LicenseNumber
		WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 3" "State" $0
		ReadRegStr $0 HKLM "SOFTWARE\ACD Systems\ACDInTouch" UserName
		WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 7" "State" $0
		ReadRegStr $0 HKLM "SOFTWARE\ACD Systems\ACDInTouch" CompanyName
		WriteINIStr "$PLUGINSDIR\ACDSee.ini" "Field 9" "State" $0
		ReadRegStr $0 HKLM "SOFTWARE\ACD Systems\ACDInTouch" UserEMail
		WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 11" "State" $0
	
		ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" Desktop
		WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 13" "State" $0
		ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" StartMenu
		WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 14" "State" $0
		ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" QuickLaunch
		WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 15" "State" $0
		ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee" ContextMenu
		WriteINIStr "$PLUGINSDIR\acdsee.ini" "Field 20" "State" $0
	${EndIf}
FunctionEnd

Function CheckDependence
	!insertmacro SelectIfSet ${ico}
	!insertmacro SelectIfSet ${psd}
	!insertmacro SelectIfSet ${psp}
	!insertmacro SelectIfSet ${sgi}
	!insertmacro SelectIfSet ${pcd}
	!insertmacro SelectIfSet ${jp2}
	!insertmacro SelectIfSet ${icn}
	!insertmacro SelectIfSet ${zip}
	!insertmacro SelectIfSet ${lha}
	!insertmacro SelectIfSet ${rar}
	!insertmacro SelectIfSet ${raw}
FunctionEnd

Function ComponentPre
	Push $0
	Push $1
	
	FindWindow $0 "#32770" "" $HWNDPARENT
  GetDlgItem $1 $0 1017
	ShowWindow $1 ${SW_HIDE}
	
	Call ResetSectionText
	
	;隐藏 Asscoiations
	${For} $0 ${association} ${end}
		SectionSetText $0 ""
	${Next}
	
	;HTML 像册生成器 和 图册实用工具 在 2000、98 下无法使用
	ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
	${If} $0 == ""
	${OrIf} $0 == "5.0"
		!insertmacro UnselectSection ${cx_html}
		!insertmacro UnselectSection ${cx_csheet}
		SectionSetText ${cx_html} ""
		SectionSetText ${cx_csheet} ""
	${EndIf}
	
	Pop $1
	Pop $0
FunctionEnd

Function ComponentShow
	Push $0
	Push $1
		${For} $1 ${main} ${post}
			ReadINIStr $0 "$PLUGINSDIR\gaydata.ini" "secnames" "sec$1"
			SectionSetText $1 $0
		${Next}
	Pop $1
	Pop $0
FunctionEnd

Function AsscoiationPre
	Push $0
	Push $1
		Call ResetSectionText
		;隐藏 Components
		${For} $0 ${main} ${post}
			SectionSetText $0 ""
		${Next}
		Call CheckDependence
	Pop $1
	Pop $0
FunctionEnd

Function AsscoiationShow
	Push $0
	Push $1
		${For} $1 ${association} ${end}
			ReadINIStr $0 "$PLUGINSDIR\gaydata.ini" "secnames" "sec$1"
			SectionSetText $1 $0
		${Next}
	Pop $1
	Pop $0
FunctionEnd

Function ResetSectionText
	Push $R0
	Push $R1
		${For} $R1 ${main} ${end}
			ReadINIStr $R0 "$PLUGINSDIR\gaydata.ini" "secnames" "sec$R1"
			${If} $R0 == ""
				SectionSetText $R1 ""
			${Else}
				SectionSetText $R1 " "
			${EndIf}
		${Next}
	Pop $R1
	Pop $R0
FunctionEnd

Function SetCustom
  InstallOptions::initDialog /NOUNLOAD $PLUGINSDIR\acdsee.ini
  !insertmacro MUI_HEADER_TEXT "个性化设置" "请输入你需要定制的个人信息"
 	InstallOptions::show
FunctionEnd	

Function ChageFONT
	GetDlgItem $0 $MUI_HWND 1201
	CreateFont $1 "Tahoma" "11" "700"
	SendMessage $0 ${WM_SETFONT} $1 0
FunctionEnd	

;******************************************************
; 卸载段
;******************************************************


Section Uninstall
	Call un.Restore
	FindWindow $0 "Afx:400000:8"
	SendMessage $0 ${WM_CLOSE} 0 0
	Call un.DelReg
	
	Push "$INSTDIR\install.log"
	Call un.DelFileByLog
	Push "$INSTDIR\install.log"
	Call un.RMDirByLog
	Delete "$INSTDIR\install.log"
	RMDir "$INSTDIR"
	
  System::Call 'shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)'
	
	${If} ${RebootFlag}
		MessageBox MB_YESNO|MB_ICONEXCLAMATION "某个文件需要重启后才能删除,现在重新启动吗?" IDNO +2
		Reboot
	${ElseIf} ${FileExists} $INSTDIR
		MessageBox MB_OK|MB_ICONINFORMATION "某些文件并不是安装程序产生的,因此需要你手动删除"
		ExecShell open $INSTDIR SW_SHOWMAXIMIZED
	${EndIf}
SectionEnd

Function un.Restore
  Push $R0
  Push $R1
  Push $R2
  Push $R3
	
  StrCpy $R0 0
  loop:
    EnumRegValue $R1 HKCR "ACDSee.FILE" $R0
    ReadRegStr $R3 HKCR ".$R1\UndoClass" ""
		
    StrCmp $R1 "" loop_quit
		
    StrCmp $R3 "" 0 restore                ;如果备份的是空值则直接删除
    DeleteRegKey HKCR ".$R1"
		DeleteRegKey HKCR "ACDSee.$R1"
    DetailPrint ".$R1 文件关联已被移除"
    Goto cont_restore
		
    restore:
    ReadRegStr $R2 HKCR ".$R1" ""
    StrCpy $R2 $R2 7
    StrCmp $R2 "ACDSee." 0 no_restore
    WriteRegStr HKCR ".$R1" "" "$R3"
		DeleteRegKey HKCR "ACDSee.$R1"
    DetailPrint ".$R1 文件关联已被恢复"
    Goto cont_restore
		
    no_restore:
    DetailPrint ".$R1 未被关联到 ACDSee,略过"
		
    cont_restore:
    IntOp $R0 $R0 + 1
    Goto loop
  loop_quit:
	
  StrCpy $R0 0 ;清除关联的压缩文档
  loop2:
    EnumRegValue $R1 HKCR ACDSee.File\Archive $R0
		StrCmp $R1 "" loop2_quit
		EnumRegKey $R2 HKCR $R1 0
		StrCmp $R2 "" +2
		DeleteRegKey HKCR $R1
    IntOp $R0 $R0 + 1
    Goto loop2
  loop2_quit:
	
	DeleteRegKey HKCR .apl
	DeleteRegKey HKCR ACD.PlugIn
	DeleteRegKey HKCR ACDSee.FILE
	
  Pop $R3
  Pop $R2
  Pop $R1
  Pop $R0
FunctionEnd

Function un.DelFileByLog
	Exch $R0
	Push $R1
	Push $R2
	Push $R3
	
	FileOpen $R0 $R0 r
	${Do}
	  FileRead $R0 $R1
		StrCpy $R1 $R1 -2
		StrCpy $R2 $R1 11
		StrCpy $R3 $R1 20
		${If} $R2 == "File: wrote"
		${OrIf} $R2 == "File: skipp"
		${OrIf} $R3 == "CreateShortCut: out:"
		${OrIf} $R3 == "created uninstaller:"
			Push $R1
			Push '"'
			Call un.StrLoc
			Pop $R2
			${If} $R2 != ""
				IntOp $R2 $R2 + 1
				StrCpy $R3 $R1 "" $R2
				Push $R3
				Push '"'
				Call un.StrLoc
				Pop $R2
				${If} $R2 != ""
					StrCpy $R3 $R3 $R2
					Delete /REBOOTOK $R3
				${EndIf}
			${EndIf}
		${EndIf}
		StrCpy $R2 $R1 7
		${If} $R2 == "Rename:"
			Push $R1
			Push '->'
			Call un.StrLoc
			Pop $R2
			${If} $R2 != ""
				IntOp $R2 $R2 + 2
				StrCpy $R3 $R1 "" $R2
				Delete /REBOOTOK $R3
			${EndIf}
		${EndIf}
	${LoopUntil} $R1 == ""
	FileClose $R0
		
	Pop $R3
	Pop $R2
	Pop $R1
	Pop $R0
FunctionEnd

Function un.RMDirByLog
	Exch $R0
	Push $R1
	Push $R2
	Push $R3
	Push $R4
	
	FileOpen $R0 $R0 r
	FileSeek $R0 16 END $R1
	${Do}
		FileSeek $R0 -3 CUR $R1
		FileReadByte $R0 $R2
		FileReadByte $R0 $R3
		${If} "$R2$R3" == "1310"
			FileRead $R0 $R2
			FileSeek $R0 $R1
			StrCpy $R3 $R2 16
			${If} $R3 == "CreateDirectory:"
				Push $R2
				Push '"'
				Call un.StrLoc
				Pop $R3
				${If} $R3 != ""
					IntOp $R3 $R3 + 1
					StrCpy $R3 $R2 "" $R3
					Push $R3
					Push '"'
					Call un.StrLoc
					Pop $R2
					${If} $R2 != ""
						StrCpy $R2 $R3 $R2
						; ----------------------特殊目录则跳过
						${If} $R2 != $PLUGINSDIR
						${AndIf} $R2 != $PROGRAMFILES
						${AndIf} $R2 != $COMMONFILES
						${AndIf} $R2 != $DESKTOP
						${AndIf} $R2 != $STARTMENU
						${AndIf} $R2 != $SMPROGRAMS
						${AndIf} $R2 != $SMSTARTUP
						${AndIf} $R2 != $QUICKLAUNCH
						${AndIf} $R2 != $FAVORITES
							RMDir $R2 ;如果是空目录则删除
						${EndIf}
						; ----------------------
					${EndIf}
				${EndIf}
			${EndIf}
		${EndIf}
	${LoopUntil} $R1 < 10
	FileClose $R0
	
	Pop $R4
	Pop $R3
	Pop $R2
	Pop $R1
	Pop $R0
FunctionEnd

Function un.StrLoc
	Exch $R0 ;Str to search for
	Exch
	Exch $R1 ;string
	Push $R2 ;len of Str to search for
	Push $R3 ;len of string
	Push $R4
	Push $R5
		StrLen $R2 $R0
		StrLen $R3 $R1
		${Do}
			StrCpy $R5 $R1 $R2 $R4
			${If} $R5 == $R0
			${OrIf} $R4 = $R3
				${ExitDo}
			${EndIf}
			IntOp $R4 $R4 + 1
		${Loop}
		${If} $R4 = $R3
			StrCpy $R0 ""
		${Else}
			StrCpy $R0 $R4
		${EndIf}	
	Pop $R5
	Pop $R4
	Pop $R3
	Pop $R2
	Pop $R1
	Exch $R0
FunctionEnd	

Function un.DelReg
  ReadRegStr $0 HKCR "CLSID\{68f32140-2ca3-11d0-acc1-444553540000}" ""
  ${If} $0 != ""
		DeleteRegKey HKCU "Software\ACD Systems\PicaView"
		DeleteRegKey HKLM "Software\ACD Systems\PicaView"
		DeleteRegKey HKCR "CLSID\{68f32140-2ca3-11d0-acc1-444553540000}"
		DeleteRegKey HKCR "PicaViewImage"
		DeleteRegValue HKCR "*\shellex\ContextMenuHandlers\PicaView" ""
		DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" "{68f32140-2ca3-11d0-acc1-444553540000}"
  ${EndIf}
	
	DeleteRegValue HKLM "SOFTWARE\ACD Systems\ACDSee" InstallationDate
	DeleteRegValue HKLM "SOFTWARE\ACD Systems\ACDSee" InTouchSettings
	DeleteRegValue HKLM "SOFTWARE\ACD Systems\ACDSee" LicenseNumber
	DeleteRegValue HKLM "SOFTWARE\ACD Systems\ACDSee" ServerList
	DeleteRegValue HKLM "SOFTWARE\ACD Systems\ACDSee" UsageCount
	DeleteRegKey /ifempty HKLM "SOFTWARE\ACD Systems\ACDSee"
	DeleteRegKey /ifempty HKLM "SOFTWARE\ACD Systems"
	DeleteRegKey HKCU "SOFTWARE\ACD Systems\PlugInsV1"
	DeleteRegKey HKCU "SOFTWARE\ACD Systems\PicaView"
	DeleteRegKey HKLM "SOFTWARE\ACD Systems\PlugInsV1"
	DeleteRegKey HKLM "SOFTWARE\ACD Systems\PicaView"
	DeleteRegKey HKLM "SOFTWARE\ACD Systems\ACDInTouch"
	DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ACDSee"
FunctionEnd