nsis 绿化程序UI源码

#压缩设置
SetCompressor /SOLID lzma
SetCompressorDictSize 32
SetDatablockOptimize on
SetCompress auto
#预先载入文件,方便安装加速释放
Reservefile "Res\iewb_net.ini"
ReserveFile "Res\header.bmp"
ReserveFile "${NSISDIR}\Plugins\System.dll"
#头文件
!include "MUI.nsh"
!include "logiclib.nsh"
!include "WinMessages.nsh"
!include "UsefulLib.nsh"
#界面相关
;只有单击"取消"才能取消安装
;!define MUI_ABORTWARNING
;!define MUI_ABORTWARNING_TEXT "你确定要退出?"
!define MUI_ICON "Res\io.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "Res\header.bmp"
!define MUI_CUSTOMFUNCTION_GUIINIT .MyGUIInit
!define MUI_FINISHPAGE_NOAUTOCLOSE
page custom show leave
#相关宏
!insertmacro MUI_LANGUAGE "SimpChinese"
#使用自定义UI
ChangeUI all "C:\Documents and Settings\Administrator\桌面\绿化工具\Contrib\default.exe"
#程序设置
Caption "绿化工具"
OutFile "绿化工具.exe"
XPStyle on
#程序执行前操作
Function .oninit
InitPluginsDir
;设置输出路径且当路径不存在时创建,设定当前的工作目录
SetOutPath $PluginsDIR
;释放文件
File "Res\iewb_net.ini"
;检测"要检测的文件"是否存在,当文件存在时跳转
;IfFileExists "$EXEDIR\*.exe" PathGood
;MessageBox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST "请把绿化工具复制到程序所在文件夹下运行。"
;Abort
;PathGood:
Functionend
#定义要创建的控件(ID不能重复,否则会产生未知错误!)
;定义关于按钮
!ifndef IDC_BUTTON
!define IDC_BUTTON 1190
!endif
;定义链接
!ifndef IDC_LINKER
!define IDC_LINKER 1200
!endif
;创建公共函数
!macro MYMACRO un
Function ${un}.AboutButton
MessageBox MB_OK|MB_ICONINFORMATION "启光博客$\nwww.iewb.net"
FunctionEnd
Function ${un}.MyGUIInit
InitPluginsDir
;创建按钮
;用法:${CreateButton2} 显示文本 X轴位置 Y轴位置 宽度 高度 父窗口窗口句柄 控件ID 目标函数
${CreateButton2} "关于(&A)" 118 192 68 18 $HWNDPARENT ${IDC_BUTTON} ${un}.AboutButton
;创建链接
${CreateLinker2} "启光博客" 20 194 80 $2 $HWNDPARENT ${IDC_LINKER} "http:/www.iewb.net"
FunctionEnd
Function ${un}.onGUIEnd
ButtonLinker::unload
FunctionEnd
!macroend
;插入安装函数
!insertmacro MYMACRO ""
#函数定义
Function show
installoptions::initdialog /nounload $PluginsDIR\iewb_net.ini
installoptions::show
Functionend
Function leave
ReadINIStr $0 "$PluginsDIR\iewb_net.ini" Settings State
${Switch} $0
${Default}
Abort
${Case} 2
Call inst
Abort
${Case} 3
Call uninst
Abort
${Case} 0
${EndSwitch}
Functionend
Function inst
;在这里放上绿化的代码
;………………..
;刷新屏幕
;System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
MessageBox MB_OK|MB_ICONINFORMATION "绿化完成!"
Return
FunctionEnd
Function uninst
;在这里放上卸载的代码
;………………..
MessageBox MB_OK|MB_ICONINFORMATION "卸载完成!"
Return
FunctionEnd
#区段定义
Section "-形式而已"
sectionend
© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容