暴风影音去广告补丁源代码公布
曾经答应过的事,现在整理好了,这几天事情多也差点忘了。NSIS写的小东西,没想到喜欢的人还不少,苦于最近时间不多,特将源码贴出,希望有能力或者想继续的朋友接力。想学NSIS的朋友,希望这个对你们也有些用处吧。没啥技术含量,所以可以随意转载,但是最好请注明出处。谢谢!
1 ;暴风影音去广告补丁
2 ;编写:寒星
3
4 !define PRODUCT_NAME "暴风影音去广告补丁"
5 !define PRODUCT_VERSION "v1.6版"
6 !define PRODUCT_PUBLISHER "寒星工作室"
7 !define PRODUCT_WEB_SITE http://www.bestdong.cn
8 SetCompressor /solid lzma
9 SetCompressorDictSize 32
10
11 ;----------------基础信息--------------------------------------
12 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
13 SetDatablockOptimize on
14 outfile "Storm3 NoAD v1.6.exe"
15 Caption "暴风影音3去广告补丁 v1.6"
16 BrandingText " 寒星工作室 ${__DATE__} "
17
18 ;---------------------安装代码使用-------------------------------
19 !include "MUI.nsh"
20 !include "UsefulLib.nsh"
21 !define MUI_ICON "Storm.ico"
22 Page custom Storm2
23 Page custom do
24 !insertmacro MUI_LANGUAGE "SimpChinese"
25 ChangeUI all default.exe
26 MiscButtonText "" "执行" "" "完成"
27
28 ;---------------------版本信息--------------------------------
29 VIProductVersion "1.6.0.0314"
30 VIAddVersionKey /LANG=${LANG_SimpChinese} "FileVersion" "1.6.0.0314"
31 VIAddVersionKey /LANG=${LANG_SimpChinese} "ProductName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
32 VIAddVersionKey /LANG=${LANG_SimpChinese} "Comments" "${PRODUCT_NAME}"
33 VIAddVersionKey /LANG=${LANG_SimpChinese} "CompanyName" "寒星工作室"
34 VIAddVersionKey /LANG=${LANG_SimpChinese} "LegalCopyright" "版权所有 (C) 寒星工作室"
35 VIAddVersionKey /LANG=${LANG_SimpChinese} "FileDescription" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
36 ;---------------------------------------------------------
37
38 Section
39 SectionEnd
40
41 ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
42 ReserveFile "Storm216.ini"
43 ReserveFile "TOP.bmp"
44
45 Function Storm2
46 !addplugindir E:\安装制作\NSIS\Plugins
47 FindProcDLL::FindProc "Storm.exe"
48 StrCmp $R0 1 +3 +1
49 FindProcDLL::FindProc "Storm2.exe"
50 StrCmp $R0 1 +1 +4
51 MessageBox MB_ICONINFORMATION|MB_RETRYCANCEL "安装程序检测到 暴风影音 正在运行!请退出程序重试或取消本次安装!" IDRetry retry IDCANCEL Cancel
52 Retry:
53 Goto -5
54 Cancel:
55 Quit
56
57 InitPluginsDir
58 File /oname=$PLUGINSDIR\Storm216.ini "Storm216.ini"
59 File /oname=$PLUGINSDIR\top.bmp "top.bmp"
60 WriteINIStr "$PLUGINSDIR\Storm216.ini" "Field 1" "Text" $PLUGINSDIR\top.bmp
61 ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\storm2" "DisplayIcon"
62 StrCpy $R2 $R1 -9
63 WriteINIStr "$PLUGINSDIR\Storm216.ini" "Field 5" "State" $R2
64
65 InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\Storm216.ini"
66 Pop $0
67 InstallOptions::show
68 Pop $0
69
70 FunctionEnd
71
72
73 Function Do
74 ReadINIStr $R3 "$PLUGINSDIR\Storm216.ini" "Field 5" "State"
75 IfFileExists "$R3\Storm.exe" +3 +1
76 MessageBox MB_ICONINFORMATION|MB_OK " 我很确定您没有安装暴风影音!点击 确定 后退出!"
77 Quit
78 SetOutPath "$R3\Media"
79 IfFileExists "$R3\stcon.ini" +1 +3
80 File /a stcon.ini
81 File /a video_style_list.xml
82 SetOutPath "$R3\"
83 IfFileExists "$R3\Media2.dll" +1 +2
84 Delete "$R3\Media2.dll"
85 CreateDirectory "$R3\Media2.dll"
86
87 ReadINIStr $R4 "$PLUGINSDIR\Storm216.ini" "Field 6" "State"
88 StrCmp $R4 1 +1 +15
89 !addplugindir E:\NSIS\Plugins
90 KillProcDLL::KillProc "stormliv.exe"
91 Rename "$R3\stormliv.exe" "$R3\stormliv.bak"
92 CreateDirectory "$R3\stormliv.exe"
93 SetShellVarContext all
94 SetOutPath "$APPDATA\Storm\Temp\"
95 Rename "update.exe" "update.bak"
96 CreateDirectory "$APPDATA\Storm\Temp\update.exe"
97 Services::SendServiceCommand 'Stop' 'ccosm'
98 Services::SendServiceCommand 'Delete' 'ccosm'
99
100 ReadINIStr $R5 "$PLUGINSDIR\Storm216.ini" "Field 7" "State"
101 StrCmp $R5 1 +1 +2
102 SetOutPath $R3
103 File "restore.exe"
104
105 MessageBox MB_ICONINFORMATION|MB_OK "去广告和删服务补丁完毕,点击 确定 后退出!"
106 Goto +2
107 MessageBox MB_ICONINFORMATION|MB_OK "补丁应用完毕,点击 确定 后退出!"
108 FunctionEnd
转自:http://www.hxlive.cn/read-285.html