【问题标题】:How to call an nsi function in uninstall section?如何在卸载部分调用 nsi 函数?
【发布时间】:2015-12-12 09:31:03
【问题描述】:

我有一个 nsi 脚本,其函数返回我试图在卸载部分调用的输出。然而不幸的是,当我运行它时,显然由于我调用此函数的方式而出现错误。我的理解是在卸载部分有一种特殊的调用函数的方法,但我不确定如何,我想知道是否有人可以帮助我?我的代码如下所示:

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 

【问题讨论】:

    标签: windows nsis


    【解决方案1】:

    卸载程序函数的名称必须以un.为前缀:

    Function un.DoMagic
    ...
    FunctionEnd
    
    Section "un.Main"
    Call un.DoMagic
    SectionEnd
    

    【讨论】:

      【解决方案2】:

      NSIS 具有命名条件 - 从卸载程序调用的函数必须具有“un”。名称中的前缀。当您有一些可以从安装程序和卸载程序调用的功能时,这很无聊。 为了避免更少的复制过去,有经验的人通常使用宏。 像这样的:

      !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
      

      【讨论】:

        猜你喜欢
        • 2018-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-01
        • 1970-01-01
        • 2012-10-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多