Function与FunctionEnd:定义一个函数。自定义函数使用call命令调用。 Function func #定义名字为func的函数 # some commands FunctionEnd Section Call func #调用func函数 SectionEnd Callback Function:回调函数。回调函数具有特殊的名称。以下是可用的回调函数列表。
!include "WinMessages.nsh" Function .onGUIInit #定义回调函数 # 1028 is the id of the branding text control GetDlgItem $R0 $HWNDPARENT 1028 CreateFont $R1 "Tahoma" 10 700 SendMessage $R0 ${WM_SETFONT} $R1 0 # set background color to white and text color to red SetCtlColors $R0 FFFFFF FF0000 FunctionEnd
Function .onInit #定义回调函数 MessageBox MB_YESNO "This will install. Continue?" IDYES NoAbort Abort ; causes installer to quit. #根据弹框内容确定是否终止安装。 NoAbort: FunctionEnd Function .onInit #定义回调函数 ReadINIStr $INSTDIR $WINDIR\wincmd.ini Configuration InstallDir StrCmp $INSTDIR "" 0 NoAbort MessageBox MB_OK "Windows Commander not found. Unable to get install path." Abort ; causes installer to quit. #根据弹框内容确定是否终止安装。 NoAbort: FunctionEnd
Function .onInstFailed MessageBox MB_OK "Better luck next time." FunctionEnd
Function .onInstSuccess MessageBox MB_YESNO "Congrats, it worked. View readme?" IDNO NoReadme Exec notepad.exe ; view readme or whatever, if you want. NoReadme: FunctionEnd
Function .onMouseOverSection FindWindow $R0 "#32770" "" $HWNDPARENT GetDlgItem $R0 $R0 1043 #获取显示Section节点描述的对象。 StrCmp $0 0 "" +2 SendMessage $R0 ${WM_SETTEXT} 0 "STR:first section description" #设置第一个Section的描述内容 StrCmp $0 1 "" +2 SendMessage $R0 ${WM_SETTEXT} 0 "STR:second section description" #设置第二个Section的描述内容 FunctionEnd
Function .onRebootFailed MessageBox MB_OK|MB_ICONSTOP "Reboot failed. Please reboot manually." /SD IDOK FunctionEnd
Function .onUserAbort MessageBox MB_YESNO "Abort install?" IDYES NoCancelAbort Abort #此时,安装不会被终止 NoCancelAbort: FunctionEnd
Function .onVerifyInstDir IfFileExists $INSTDIR\Winamp.exe PathGood Abort #表示选择的安装路径无效,无法进行下一步。 PathGood: FunctionEnd
|
|