简体   繁体   English

从 nsh 文件 nsis 中检索变量值

[英]retrieve variable value from nsh file nsis

I am creating installer using nsis.我正在使用 nsis 创建安装程序。 I have created .nsh file using SIMPLE SC to start, stop and remove services.我已经使用 SIMPLE SC 创建了 .nsh 文件来启动、停止和删除服务。 I have used macros for this.我为此使用了宏。

When I call this in nsi file it works.当我在 nsi 文件中调用它时,它可以工作。 But I would like to know the return value for start service (SimpleSC::StartService "${SVC}" "${Args}" "${Timeout}", Pop $0).但我想知道启动服务的返回值(SimpleSC::StartService "${SVC}" "${Args}" "${Timeout}", Pop $0)。 how do I retrieve the $0 value of nsh file in my nsis file如何在我的 nsis 文件中检索 nsh 文件的 $0 值

If you have some helper macros that return a result, you can leave the result on the stack:如果您有一些返回结果的辅助宏,您可以将结果留在堆栈中:

!macro DoSomething
Push $0
Push $1

Push "Pretend that this is a function that does something and puts the result on the stack"
Pop $0 ; Result we want to return

Pop $1
Exch $0
!macroend

!insertmacro DoSomething
Pop $0
MessageBox MB_OK $0

or store it in a register as part of the macro:或将其作为宏的一部分存储在寄存器中:

!macro DoSomething outvar
Push $0
Push $1

Push "Pretend that this is a function that does something and puts the result on the stack"
Pop $0 ; Result we want to return

Pop $1
Exch $0
Pop ${outvar}
!macroend

!insertmacro DoSomething $0
MessageBox MB_OK $0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM