如何在卸载部分调用 nsi 函数?
How to call an nsi function in uninstall section?
我有一个 nsi 脚本,其中 returns 输出我试图在卸载部分调用的函数。不幸的是,当我 运行 它时,由于调用此函数的方式,我显然会出错。我的理解是在卸载部分有一种调用函数的特殊方法,但我不确定如何调用函数,我想知道是否有人可以帮助我?我的代码如下所示:
Function TestFunction
Push $R0
Rush $R1
;do stuff
Pop $R!
Exch $R0
FunctionEnd
!macro TestFunction OUTPUT_VALUE
Call TestFunction
Pop `${OUTPUT_VALUE}`
!macroend
!define TestFunction'!insertmacro "TestFunction"'
; Uninstaller
Section "Uninstall"
${TestFunction} $R0
StrCmp $R0 "Test" istest isnottest
卸载函数的名称必须以un.
:
为前缀
Function un.DoMagic
...
FunctionEnd
Section "un.Main"
Call un.DoMagic
SectionEnd
NSIS 有命名条件 - 从卸载程序调用的函数名称中必须有 "un." 前缀。当您有一些可以从安装程序和卸载程序调用的功能时,这很无聊。
为了避免复制过去,有经验的人通常使用 macroses。
像这样:
!macro TestFunction UN
Function ${UN}TestFunction
;do stuff
FunctionEnd
!macroend
!insertmacro TestFunction ""
!insertmacro TestFunction "un."
使用:
Section "Install"
Call TestFunction
EndSection
Section "Uninstall"
Call un.TestFuction
SecionEnd
我有一个 nsi 脚本,其中 returns 输出我试图在卸载部分调用的函数。不幸的是,当我 运行 它时,由于调用此函数的方式,我显然会出错。我的理解是在卸载部分有一种调用函数的特殊方法,但我不确定如何调用函数,我想知道是否有人可以帮助我?我的代码如下所示:
Function TestFunction
Push $R0
Rush $R1
;do stuff
Pop $R!
Exch $R0
FunctionEnd
!macro TestFunction OUTPUT_VALUE
Call TestFunction
Pop `${OUTPUT_VALUE}`
!macroend
!define TestFunction'!insertmacro "TestFunction"'
; Uninstaller
Section "Uninstall"
${TestFunction} $R0
StrCmp $R0 "Test" istest isnottest
卸载函数的名称必须以un.
:
Function un.DoMagic
...
FunctionEnd
Section "un.Main"
Call un.DoMagic
SectionEnd
NSIS 有命名条件 - 从卸载程序调用的函数名称中必须有 "un." 前缀。当您有一些可以从安装程序和卸载程序调用的功能时,这很无聊。 为了避免复制过去,有经验的人通常使用 macroses。 像这样:
!macro TestFunction UN
Function ${UN}TestFunction
;do stuff
FunctionEnd
!macroend
!insertmacro TestFunction ""
!insertmacro TestFunction "un."
使用:
Section "Install"
Call TestFunction
EndSection
Section "Uninstall"
Call un.TestFuction
SecionEnd