目前,我有以下脚本代码.
Section "Uninstall"
...
...
Call un.DeleteDirIfEmpty
SectionEnd
Function GetJRE
; Call must not be used with functions starting with "un." in the non-uninstall sections.
Call
FunctionEnd
Function un.DeleteDirIfEmpty
...
...
FunctionEnd
Function DeleteDirIfEmpty
...
...
FunctionEnd
Run Code Online (Sandbox Code Playgroud)
请注意,我需要提供2个版本的DeleteDirIfEmpty,以便可以在非卸载部分和卸载部分中执行相同的操作.
他们的代码是相同的,只是命名是不同的.un.DeleteDirIfEmpty和DeleteDirIfEmpty
如何只有1个函数,但可以被任何部分调用?
看看\ Include\Util.nsh,它用于将宏转换为函数:
!include Util.nsh
!macro MyFunction
MessageBox mb_ok "Hello World"
!macroend
!define MyFunction "${CallArtificialFunction} MyFunction"
Section
${MyFunction}
SectionEnd
Run Code Online (Sandbox Code Playgroud)
注意:要删除空目录,只需使用RMDir(不带/ r开关)