如何在NSIS安装程序脚本中捕获没有gotos / labels的YESNOCANCEL
发布时间:2020-12-14 05:53:22 所属栏目:Windows 来源:网络整理
导读:我想知道如何在NSIS安装程序脚本中使用YESNOCANCEL MessageBox和LogicLib.nsh中的IF逻辑,以避免使用标签和gotos. 有没有办法在某种变量中捕获MessageBox的结果? 此外,我知道有比NSIS更好的东西,但在这一点上使用其他东西不是可能的. =( 请注意以下代码中的{
|
我想知道如何在NSIS安装程序脚本中使用YESNOCANCEL MessageBox和LogicLib.nsh中的IF逻辑,以避免使用标签和gotos.
有没有办法在某种变量中捕获MessageBox的结果? 此外,我知道有比NSIS更好的东西,但在这一点上使用其他东西不是可能的. =( 请注意以下代码中的{WHAT GOES HERE ??}.如果这只是一个If … Else ……它会正常工作. 谢谢您的帮助 ${If} ${Cmd} `MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION
"PROGRAM X is already installed. Click YES to remove the installed version
found in C:Program Files(x86). Click NO to skip uninstall and choose a
different install location (not recommended) or CANCEL to terminate
the installer." IDYES`
MessageBox MB_OK "Yes was clicked"
${ElseIf} {WHAT GOES HERE??}
MessageBox MB_OK "No was clicked"
${Else}
MessageBox MB_OK "Cancel was clicked"
${EndIf}
更新: ; ifcmd..||..| and if/unless cmd
StrCpy $R2 ""
${IfCmd} MessageBox MB_YESNO "Please click Yes" IDYES ${||} StrCpy $R2 $R2A ${|}
${Unless} ${Cmd} `MessageBox MB_YESNO|MB_DEFBUTTON2 "Please click No" IDYES`
StrCpy $R2 $R2B
${EndUnless}
${If} $R2 == "AB"
DetailPrint "PASSED IfCmd/If Cmd test"
${Else}
DetailPrint "FAILED IfCmd/If Cmd test"
${EndIf}
解决方法
以${|}结尾的行表示如果条件为真,则执行单个指令的if块:
${IfThen} $Instdir == $Temp ${|} MessageBox mb_ok "$$InstDir equals $$Temp" ${|}
这只是简写语法: ${If} $Instdir == $Temp
MessageBox mb_ok "$$InstDir equals $$Temp"
${EndIf}
IfCmd宏在内部使用${IfThen} ${Cmd},${||}是一个黑客来结束由IfCmd启动的字符串引用,所以: ${IfCmd} MessageBox MB_YESNO "click yes" IDYES ${||} MessageBox mb_ok choice=IDYES ${|}
是简写: ${If} ${Cmd} 'MessageBox MB_YESNO "yes" IDYES' ;notice the quotes here
MessageBox mb_ok choice=IDYES
${EndIf}
你甚至可以混合ifthen和标签,但这是丑陋的恕我直言: StrCpy $0 "Cancel"
${IfCmd} MessageBox MB_YESNOCANCEL "Mr. Powers?" IDYES yes IDNO ${||} StrCpy $0 "NO?!" ${|}
MessageBox mb_iconstop $0 ;Cancel or NO
goto end
yes:
MessageBox mb_ok "Yeah baby yeah!"
end:
(最好只使用MessageBox for YESNOCANCEL和ABORTRETRYIGNORE,对于YESNO,OKCANCEL等,为两个选项执行不同的代码,使用${If} ${Cmd}’MessageBox ..’.. ${Else} .. ${EndIf}语法) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 华硕b450m pro gaming/r5 2600超频设置
- Windows Phone 7 – SkyDrive的编程访问
- xaml – 使用ScrollViewer内部捕获操作类事件(Windows Phon
- 双系统安装,引导被覆盖-如何解决?
- windows – 作为服务运行时,QtService应用程序无法连接到系
- windows – 为什么最大化的Delphi形式比GetSystemMetrics值
- 常用Windows消息合集
- Windows Azure Access Control和Windows Phone 8
- windows-server-2012-r2 – Windows Server 2012 R2关闭事件
- windows-phone-7 – 在Windows Phone 7中引用合并的资源字典
推荐文章
站长推荐
- windows – slmgr.vbs supress对话框
- x32下的DLL隐藏
- windows-phone-7 – Windows phone OS 7.0 vs OS
- windows-8 – WinRT XAML中的RadialGradientBrus
- 身份验证–Windows Phone 10 Google Web授权代理
- 拒绝服务 – Synology DSM 5中启用DoS保护的作用
- windows-7 – 为什么NTOSKRNL.exe IMAGE_MACHINE
- windows-8 – 如何在Windows 8.1(IE11和Modern U
- xaml – Windows应用商店应用布局差异
- windows – 启动进程时“print”和“printo”动词
热点阅读
