从nsh文件nsis检索变量值

时间:2020-10-23 04:25:46

标签: windows installation service macros nsis

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

当我在nsi文件中调用它时,它可以工作。但是我想知道启动服务的返回值(SimpleSC :: StartService“ $ {SVC}”“ $ {Args}”“ $ {Timeout}”,弹出$ 0)。如何在我的nsis文件中检索nsh文件的$ 0值

1 个答案:

答案 0 :(得分:0)

如果您有一些返回结果的助手宏,则可以将结果保留在堆栈中:

!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

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

!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