程序:暴风影音2去广告补丁

优质
小牛编辑
142浏览
2023-12-01
本例中使用了3个插件:
FindProcDLL
KillProcDLL
Services

;暴风影音2去广告补丁
;编写:寒星

!define HAVE_UPX
!ifdef HAVE_UPX
!packhdr tmp.dat "upx -9 tmp.dat"
!endif

!define PRODUCT_NAME "暴风影音去广告补丁"
!define PRODUCT_VERSION "v1.6版"
!define PRODUCT_PUBLISHER "寒星工作室"
!define PRODUCT_WEB_SITE "http://www.hxlive.cn"
SetCompressor /solid lzma
SetCompressorDictSize 32

;----------------基础信息--------------------------------------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
SetDatablockOptimize on
outfile "Storm3 NoAD v1.6.exe"
Caption  "暴风影音3去广告补丁 v1.6"
BrandingText " 寒星工作室 ${__DATE__} "

;---------------------安装代码使用-------------------------------
!include "MUI.nsh"
!include "UsefulLib.nsh"
!define MUI_ICON "Storm.ico"
Page custom Storm2
Page custom do
!insertmacro MUI_LANGUAGE "SimpChinese"
ChangeUI all default.exe
MiscButtonText "" "执行" "" "完成"

;---------------------版本信息--------------------------------
VIProductVersion "1.6.0.0314"
VIAddVersionKey /LANG=${LANG_SimpChinese} "FileVersion" "1.6.0.0314"
VIAddVersionKey /LANG=${LANG_SimpChinese} "ProductName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
VIAddVersionKey /LANG=${LANG_SimpChinese} "Comments" "${PRODUCT_NAME}"
VIAddVersionKey /LANG=${LANG_SimpChinese} "CompanyName" "寒星工作室"
VIAddVersionKey /LANG=${LANG_SimpChinese} "LegalCopyright" "版权所有 (C) 寒星工作室"
VIAddVersionKey /LANG=${LANG_SimpChinese} "FileDescription" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
;---------------------------------------------------------

Section
SectionEnd

ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
ReserveFile "Storm216.ini"
ReserveFile "TOP.bmp"

Function Storm2
  !addplugindir E:\安装制作\NSIS\Plugins
   FindProcDLL::FindProc "Storm.exe"
    StrCmp $R0 1 +3 +1
   FindProcDLL::FindProc "Storm2.exe"
    StrCmp $R0 1 +1 +4
     MessageBox MB_ICONINFORMATION|MB_RETRYCANCEL "安装程序检测到 暴风影音 正在运行!请退出程序重试或取消本次安装!"   IDRetry retry IDCANCEL Cancel
     Retry:
      Goto -5
     Cancel:
      Quit
      
  InitPluginsDir
   File /oname=$PLUGINSDIR\Storm216.ini "Storm216.ini"
   File /oname=$PLUGINSDIR\top.bmp "top.bmp"
   WriteINIStr "$PLUGINSDIR\Storm216.ini" "Field 1" "Text" $PLUGINSDIR\top.bmp
   ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\storm2" "DisplayIcon"
   StrCpy $R2 $R1 -9
   WriteINIStr "$PLUGINSDIR\Storm216.ini" "Field 5" "State" $R2

  InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\Storm216.ini"
  Pop $0
  InstallOptions::show
  Pop $0

FunctionEnd


Function Do
  ReadINIStr $R3 "$PLUGINSDIR\Storm216.ini" "Field 5" "State"
  IfFileExists "$R3\Storm.exe" +3 +1
  MessageBox MB_ICONINFORMATION|MB_OK " 我很确定您没有安装暴风影音!点击 确定 后退出!"
   Quit
  SetOutPath "$R3\Media"
   IfFileExists "$R3\stcon.ini" +1 +3
    File /a stcon.ini
    File /a video_style_list.xml
  SetOutPath "$R3\"
   IfFileExists "$R3\Media2.dll" +1 +2
    Delete "$R3\Media2.dll"
    CreateDirectory "$R3\Media2.dll"

  ReadINIStr $R4 "$PLUGINSDIR\Storm216.ini" "Field 6" "State"
  StrCmp $R4 1 +1 +15
  !addplugindir E:\NSIS\Plugins
   KillProcDLL::KillProc "stormliv.exe"
    Rename "$R3\stormliv.exe" "$R3\stormliv.bak"
    CreateDirectory "$R3\stormliv.exe"
    SetShellVarContext all
    SetOutPath "$APPDATA\Storm\Temp\"
    Rename "update.exe" "update.bak"
    CreateDirectory "$APPDATA\Storm\Temp\update.exe"
   Services::SendServiceCommand 'Stop' 'ccosm'
   Services::SendServiceCommand 'Delete' 'ccosm'

  ReadINIStr $R5 "$PLUGINSDIR\Storm216.ini" "Field 7" "State"
  StrCmp $R5 1 +1 +2
  SetOutPath $R3
   File "restore.exe"

  MessageBox MB_ICONINFORMATION|MB_OK "去广告和删服务补丁完毕,点击 确定 后退出!"
   Goto +2
  MessageBox MB_ICONINFORMATION|MB_OK "补丁应用完毕,点击 确定 后退出!"
FunctionEnd