最新消息:

二进制在NSIS中的应用

nsis 永恒心锁 860浏览 0评论
!include nsDialogs.nsh
!define BIT_CHECK_PROGRAMS 0x00000001
!define BIT_CHECK_DESKTOP 0x00000002
!define BIT_CHECK_TASKBAR 0x00000004
Var Flags
Name Example
OutFile Example.exe
XPStyle on
InstallColors /windows
ShowInstDetails show
Page custom CustomPage.Create
Page instfiles
Section Install
SectionEnd
Function CustomPage.Create
 nsDialogs::Create 1018
 Pop $0
 GetFunctionAddress $R0 onCheckBoxClick
 ${NSD_CreateCheckBox} 0u 0u 100% 8u "Create Startmenu Shortcut"
 Pop $0
 nsDialogs::SetUserData $0 ${BIT_CHECK_PROGRAMS}
 nsDialogs::onClick $0 $R0
 IntOp $R1 $Flags & ${BIT_CHECK_PROGRAMS}
 IntCmp $R1 0 +2
 SendMessage $0 ${BM_CLICK} 0 0
 ${NSD_CreateCheckBox} 0u 12u 100% 8u "Create Desktop Shortcut"
 Pop $0
 nsDialogs::SetUserData $0 ${BIT_CHECK_DESKTOP}
 nsDialogs::onClick $0 $R0
 IntOp $R1 $Flags & ${BIT_CHECK_DESKTOP}
 IntCmp $R1 0 +2
 SendMessage $0 ${BM_CLICK} 0 0
 ${NSD_CreateCheckBox} 0u 24u 100% 8u "Create Taskbar Shortcut"
 Pop $0
 nsDialogs::SetUserData $0 ${BIT_CHECK_TASKBAR}
 nsDialogs::onClick $0 $R0
 IntOp $R1 $Flags & ${BIT_CHECK_TASKBAR}
 IntCmp $R1 0 +2
 SendMessage $0 ${BM_CLICK} 0 0
 nsDialogs::Show
FunctionEnd
Function onCheckBoxClick
 Exch $R0
 Push $R1
 Push $R2
 SendMessage $R0 ${BM_GETCHECK} 0 0 $R1
 nsDialogs::GetUserData $R0
 Pop $R2
 IntCmp $R1 ${BST_UNCHECKED} +3
 IntOp $Flags $Flags | $R2
 Goto +3
 IntOp $R2 $R2 ~
 IntOp $Flags $Flags & $R2
 Pop $R2
 Pop $R1
 Pop $R0
FunctionEnd
Function .onInstSuccess
 IntOp $R0 $Flags & ${BIT_CHECK_PROGRAMS}
 IntCmp $R0 0 +2
 MessageBox MB_OK|MB_ICONINFORMATION "Startmenu shortcut!"
 IntOp $R0 $Flags & ${BIT_CHECK_DESKTOP}
 IntCmp $R0 0 +2
 MessageBox MB_OK|MB_ICONINFORMATION "Desktop shortcut!"
 IntOp $R0 $Flags & ${BIT_CHECK_TASKBAR}
 IntCmp $R0 0 +2
 MessageBox MB_OK|MB_ICONINFORMATION "Taskbar shortcut!"
FunctionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 二进制在NSIS中的应用

您必须 登录 才能发表评论!