好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 plmoknplm 于 2022-5-11 16:16 编辑
示例
最近在学习NSIS做绿化小工具,找了个示例,用7-zip解开,获得[NSIS].nsi,但再编译,不成功,请大佬指点下,就想做个类似的绿化小工具,求能成功编译的源码示例,谢谢!
; NSIS script (UTF-8) NSIS-Park-3 Unicode log
; Install
Unicode true
SetCompressor /SOLID lzma
SetCompressorDictSize 32
; --------------------
; HEADER SIZE: 27928
; START HEADER SIZE: 300
; MAX STRING LENGTH: 8196
; STRING CHARS: 2607
OutFile [NSIS].exe
!include WinMessages.nsh
ShowInstDetails nevershow
LicenseBkColor /windows
; --------------------
; LANG TABLES: 1
; LANG STRINGS: 51
Name 名称
BrandingText "Nullsoft Install System v2.46.5-Unicode"
; LANG: 2052
LangString LSTR_0 2052 "Nullsoft Install System v2.46.5-Unicode"
LangString LSTR_1 2052 "BlinkMind 绿化工具"
LangString LSTR_2 2052 名称
LangString LSTR_5 2052 "无法写入: "
LangString LSTR_8 2052 "无法找到符号: "
LangString LSTR_9 2052 "无法加载: "
LangString LSTR_13 2052 "删除文件: "
LangString LSTR_14 2052 "重新启动后删除: "
LangString LSTR_17 2052 正在解压缩数据发生错误!已损坏的安装程序?
LangString LSTR_21 2052 "抽取: "
LangString LSTR_22 2052 "抽取: 无法写入文件 "
LangString LSTR_24 2052 "没有 OLE 用于: "
LangString LSTR_25 2052 "输出目录: "
LangString LSTR_26 2052 "移除目录: "
LangString LSTR_29 2052 "已跳过: "
LangString LSTR_30 2052 "复制细节到剪贴板 "
LangString LSTR_36 2052 "不能打开要写入的文件: $\r$\n$\t$\"$0$\"$\r$\n单击 [Abort] 放弃安装,$\r$\n [Retry] 重新尝试写入文件,或$\r$\n [Ignore] 忽略这个文件。"
LangString LSTR_37 2052 宋体
LangString LSTR_38 2052 9
LangString LSTR_39 2052 自定义
LangString LSTR_40 2052 取消(&C)
LangString LSTR_41 2052 "< 上一步(&P)"
LangString LSTR_42 2052 安装(&I)
LangString LSTR_43 2052 "单击 [安装(I)] 开始安装进程。"
LangString LSTR_44 2052 ": 正在安装"
LangString LSTR_45 2052 显示细节(&D)
LangString LSTR_46 2052 已完成
LangString LSTR_47 2052 "下一步(&N) >"
LangString LSTR_48 2052 "单击 [下一步(N)] 继续。"
LangString LSTR_49 2052 " "
LangString LSTR_50 2052 关闭(&L)
; --------------------
; VARIABLES: 3
Var _0_
Var _1_
Var _2_
InstType $(LSTR_39) ; 自定义
; wininit = $WINDIR\wininit.ini
; --------------------
; PAGES: 3
; Page 0
Page custom func_101 func_67 /ENABLECANCEL
; Page 1
Page instfiles
CompletedText $(LSTR_46) ; 已完成
DetailsButtonText $(LSTR_45) ; 显示细节(&D)
/*
; Page 2
Page COMPLETED
*/
; --------------------
; SECTIONS: 1
; COMMANDS: 198
Function .onGUIInit
InitPluginsDir
; Call Initialize_____Plugins
; SetDetailsPrint lastused
File $PLUGINSDIR\modern-header.bmp
SetBrandingImage /IMGID=1046 /RESIZETOFIT $PLUGINSDIR\modern-header.bmp
GetDlgItem $_0_ $HWNDPARENT 1037
CreateFont $_1_ $(LSTR_37) $(LSTR_38) 700 ; 宋体 9
SendMessage $_0_ ${WM_SETFONT} $_1_ 0
SetCtlColors $_0_ "" 0xFFFFFF
GetDlgItem $_0_ $HWNDPARENT 1038
SetCtlColors $_0_ "" 0xFFFFFF
GetDlgItem $_0_ $HWNDPARENT 1034
SetCtlColors $_0_ "" 0xFFFFFF
GetDlgItem $_0_ $HWNDPARENT 1039
SetCtlColors $_0_ "" 0xFFFFFF
GetDlgItem $_0_ $HWNDPARENT 1028
SetCtlColors $_0_ /BRANDING ""
GetDlgItem $_0_ $HWNDPARENT 1256
SetCtlColors $_0_ /BRANDING ""
SendMessage $_0_ ${WM_SETTEXT} 0 "STR:$(LSTR_0) " ; "Nullsoft Install System v2.46.5-Unicode"
FunctionEnd
Function .onUserAbort
FunctionEnd
Section PS ; Section_0
SectionEnd
Function .onInit
FindProcDLL::FindProc $EXEPATH
; Call Initialize_____Plugins
; SetOverwrite off
; File $PLUGINSDIR\FindProcDLL.dll
; SetDetailsPrint lastused
; Push $EXEPATH
; CallInstDLL $PLUGINSDIR\FindProcDLL.dll FindProc
StrCmp $R0 1 0 label_30
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST "$EXEFILE 已在运行中,请不要重复打开!"
Quit
label_30:
System::Call kernel32::GetCurrentProcess()i.s
; Call Initialize_____Plugins
; File $PLUGINSDIR\System.dll
; SetDetailsPrint lastused
; Push kernel32::GetCurrentProcess()i.s
; CallInstDLL $PLUGINSDIR\System.dll Call
System::Call kernel32::IsWow64Process(is,*i.s)
; Call Initialize_____Plugins
; AllowSkipFiles off
; File $PLUGINSDIR\System.dll
; SetDetailsPrint lastused
; Push kernel32::IsWow64Process(is,*i.s)
; CallInstDLL $PLUGINSDIR\System.dll Call
Pop $_2_
StrCmp $_2_ 0 label_49
System::Call kernel32::Wow64EnableWow64FsRedirection(i0)
; Call Initialize_____Plugins
; File $PLUGINSDIR\System.dll
; SetDetailsPrint lastused
; Push kernel32::Wow64EnableWow64FsRedirection(i0)
; CallInstDLL $PLUGINSDIR\System.dll Call
SetRegView 64
Goto label_51
label_49:
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST "您下载的是 BlinkMind v0.1.6 64 位版,仅支持 64 位操作系统!"
Quit
label_51:
FunctionEnd
Function func_52
IfFileExists $EXEDIR\BlinkMind.exe 0 label_55
Nop
Goto label_57
label_55:
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST "找不到程序文件: $\n$\n$EXEDIR\BlinkMind.exe"
Abort
label_57:
StrCpy $R0 ""
FindProcDLL::FindProc BlinkMind.exe
; Call Initialize_____Plugins
; File $PLUGINSDIR\FindProcDLL.dll
; SetDetailsPrint lastused
; Push BlinkMind.exe
; CallInstDLL $PLUGINSDIR\FindProcDLL.dll FindProc
StrCmp $R0 1 0 label_66
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST "BlinkMind 还在运行中: $\n$\n$EXEDIR\BlinkMind.exe$\n$\n请彻底关闭后再执行本操作!"
Abort
label_66:
FunctionEnd
Function func_67 ; Page 0, Leave
StrCpy $R7 ""
ReadINIStr $R7 $PLUGINSDIR\BlinkMind.ini Settings State
StrCmp $R7 3 0 label_82
Call func_52
MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST "确定要开始绿化安装「BlinkMind v0.1.6」吗?" IDOK label_72 IDCANCEL label_81
label_72:
Call func_164
Sleep 50
System::Call "shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)"
; Call Initialize_____Plugins
; File $PLUGINSDIR\System.dll
; SetDetailsPrint lastused
; Push "shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)"
; CallInstDLL $PLUGINSDIR\System.dll Call
Sleep 50
MessageBox MB_OK|MB_ICONINFORMATION|MB_TOPMOST "「绿 化 成 功」$\n$\n请运行主程序:$EXEDIR\BlinkMind.exe"
label_81:
Abort
label_82:
StrCmp $R7 2 0 label_95
Call func_52
MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST "确定要删除「BlinkMind v0.1.6」所有相关配置文件和数据吗?" IDOK label_85 IDCANCEL label_94
label_85:
Call func_171
Sleep 50
System::Call "shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)"
; Call Initialize_____Plugins
; File $PLUGINSDIR\System.dll
; SetDetailsPrint lastused
; Push "shell32.dll::SHChangeNotify(l, l, i, i) v (0x08000000, 0, 0, 0)"
; CallInstDLL $PLUGINSDIR\System.dll Call
Sleep 50
MessageBox MB_OK|MB_ICONINFORMATION|MB_TOPMOST "「清 理 成 功」$\n$\n直接删除程序目录完成彻底清理。"
label_94:
Abort
label_95:
StrCmp $R7 5 0 label_97
Abort
label_97:
StrCmp $R7 7 0 label_99
Abort
label_99:
Abort
FunctionEnd
Function func_101 ; Page 0, Pre
WriteINIStr $PLUGINSDIR\BlinkMind.ini Settings NumFields 7
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 1" Type Groupbox
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 1" Text "BlinkMind v0.1.6 绿化工具"
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 1" Left 0
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 1" Right 149
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 1" Top 0
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 1" Bottom 86
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 2" Type Button
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 2" Text 删除
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 2" Flags NOTIFY
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 2" Left 84
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 2" Right 135
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 2" Top 20
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 2" Bottom 41
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 3" Type Button
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 3" Text 安装
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 3" Flags NOTIFY
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 3" Left 12
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 3" Right 64
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 3" Top 20
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 3" Bottom 41
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 4" Type Label
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 4" Text "追求绿色便携理念 打造清爽干净系统"
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 4" Left 8
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 4" Right 144
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 4" Top 54
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 4" Bottom 68
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 5" Type Link
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 5" Text 检查更新
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 5" State https://www.portablesoft.org/blinkmind/
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 5" Left 36
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 5" Right 70
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 5" Top 70
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 5" Bottom 78
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 6" Type Label
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 6" Text |
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 6" Left 71
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 6" Right 75
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 6" Top 70
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 6" Bottom 78
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 7" Type Link
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 7" Text 探索更多
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 7" State https://www.portablesoft.org/go.php?id=ps
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 7" Left 80
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 7" Right 146
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 7" Top 70
WriteINIStr $PLUGINSDIR\BlinkMind.ini "Field 7" Bottom 78
Sleep 100
InstallOptions::dialog $PLUGINSDIR\BlinkMind.ini
; Call Initialize_____Plugins
; AllowSkipFiles on
; File $PLUGINSDIR\InstallOptions.dll
; SetDetailsPrint lastused
; Push $PLUGINSDIR\BlinkMind.ini
; CallInstDLL $PLUGINSDIR\InstallOptions.dll dialog
FunctionEnd
Function .onGUIEnd
SetOutPath $EXEDIR
System::Free 0
; Call Initialize_____Plugins
; File $PLUGINSDIR\System.dll
; SetDetailsPrint lastused
; Push 0
; CallInstDLL $PLUGINSDIR\System.dll Free
Delete $PLUGINSDIR\*.*
RMDir /r $PLUGINSDIR
FunctionEnd
Function func_164
WriteRegStr HKCU Software\Classes\.bmind "" BlinkMind
WriteRegStr HKCU Software\Classes\BlinkMind "" "Blink Mind Document"
WriteRegStr HKCU Software\Classes\BlinkMind\DefaultIcon "" $EXEDIR\resources\icon.ico
WriteRegStr HKCU Software\Classes\BlinkMind\shell "" open
WriteRegStr HKCU Software\Classes\BlinkMind\shell\open "" "Open with BlinkMind"
WriteRegStr HKCU Software\Classes\BlinkMind\shell\open\command "" "$EXEDIR\BlinkMind.exe $\"%1$\""
FunctionEnd
Function func_171
RMDir /r $APPDATA\BlinkMind
DeleteRegKey HKCU Software\Classes\.bmind
DeleteRegKey HKCU Software\Classes\BlinkMind
DeleteRegKey HKCU Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmind
DeleteRegValue HKCU Software\Microsoft\Windows\CurrentVersion\Search\JumplistData org.awehook.blinkminddesktop
DeleteRegValue HKCU Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts BlinkMind_.bmind
DeleteRegValue HKCU Software\Microsoft\Windows\CurrentVersion\Search\JumplistData $EXEDIR\BlinkMind.exe
DeleteRegValue HKCU Software\Microsoft\Windows\CurrentVersion\Search\JumplistData $EXEPATH
DeleteRegValue HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" $EXEDIR\BlinkMind.exe
DeleteRegValue HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" $EXEPATH
DeleteRegValue HKCU Software\Microsoft\Windows\CurrentVersion\Explorer\FeatureUsage\AppSwitched $EXEDIR\BlinkMind.exe
DeleteRegValue HKCU Software\Microsoft\Windows\CurrentVersion\Explorer\FeatureUsage\AppSwitched $EXEPATH
FunctionEnd
/*
Function Initialize_____Plugins
SetDetailsPrint none
StrCmp $PLUGINSDIR "" 0 label_194
Push $0
SetErrors
GetTempFileName $0
Delete $0
CreateDirectory $0
IfErrors label_195
StrCpy $PLUGINSDIR $0
Pop $0
label_194:
Return
label_195:
MessageBox MB_OK|MB_ICONSTOP "Error! Can't initialize plug-ins directory. Please try again later." /SD IDOK
Quit
FunctionEnd
*/
; --------------------
; UNREFERENCED STRINGS:
/*
1 ProgramFilesDir
17 "C:\Program Files"
34 $PROGRAMFILES
37 CommonFilesDir
52 "$PROGRAMFILES\Common Files"
68 $COMMONFILES
*/
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|