从 nsh 文件 nsis 中检索变量值

retrieve variable value from nsh file nsis

我正在使用 nsis 创建安装程序。我已经使用 SIMPLE SC 创建了 .nsh 文件来启动、停止和删除服务。我为此使用了宏。

当我在 nsi 文件中调用它时,它起作用了。但我想知道启动服务的 return 值(SimpleSC::StartService "${SVC}" "${Args}" "${Timeout}", Pop $0)。如何在我的 nsis 文件中检索 nsh 文件的 $0 值

如果您有一些 return 结果的辅助宏,您可以将结果留在堆栈上:

!macro DoSomething
Push [=10=]
Push 

Push "Pretend that this is a function that does something and puts the result on the stack"
Pop [=10=] ; Result we want to return

Pop 
Exch [=10=]
!macroend

!insertmacro DoSomething
Pop [=10=]
MessageBox MB_OK [=10=]

或将其作为宏的一部分存储在寄存器中:

!macro DoSomething outvar
Push [=11=]
Push 

Push "Pretend that this is a function that does something and puts the result on the stack"
Pop [=11=] ; Result we want to return

Pop 
Exch [=11=]
Pop ${outvar}
!macroend

!insertmacro DoSomething [=11=]
MessageBox MB_OK [=11=]