Macros 在卸载模式下使用嵌套在宏中的StrLoc
我不是NSIS的专家用户。。。编译脚本时,我收到以下错误:Macros 在卸载模式下使用嵌套在宏中的StrLoc,macros,nsis,uninstallation,Macros,Nsis,Uninstallation,我不是NSIS的专家用户。。。编译脚本时,我收到以下错误: !insertmacro: FUNCTION_STRING_StrLoc_Call Call must be used with function names starting with "un." in the uninstall section. 卸载时,调用以下函数: Function un.Uninstall ; some code ${un.GetMsOfficeVersion} $R0 ; some
!insertmacro: FUNCTION_STRING_StrLoc_Call
Call must be used with function names starting with "un." in the uninstall section.
卸载时,调用以下函数:
Function un.Uninstall
; some code
${un.GetMsOfficeVersion} $R0
; some code
FunctionEnd
反过来,也会调用以下代码和平:
!macro GetMsOfficeVersion
; some code
StrCpy $R0 0
loop:
ClearErrors
EnumRegValue $R1 HKCU "Microsoft\Office\16.0\Common\Licensing\LastKnownC2RProductReleaseId" $R0
IfErrors done
IntOp $R0 $R0 + 1
ReadRegStr $R2 HKCU "Microsoft\Office\16.0\Common\Licensing\LastKnownC2RProductReleaseId" $R1
${StrLoc} $R1 "$R2" "365" ">"
StrCmp $R1 "" +3 0 ;+3 if substring is not found
StrCpy $R1 "16.0"
Goto found
${StrLoc} $R1 "$R2" "2019" ">"
StrCmp $R1 "" loop 0 ;loop if substring is not found
StrCpy $R1 "16.0"
Goto found
done:
; other code
!macroend
!macro _GetMsOfficeVersion Result
${CallArtificialFunction} GetMsOfficeVersion
Pop "${Result}"
!macroend
; Insert function as an installer and uninstaller function.
!define GetMsOfficeVersion "!insertmacro _GetMsOfficeVersion"
!define un.GetMsOfficeVersion "!insertmacro _GetMsOfficeVersion"
我知道问题是因为调用了${StrLoc}
函数。在安装模式和卸载模式下应该分别不同,即${StrLoc}
和${un.StrLoc}
,但我不知道如何使用此代码结构
任何帮助都将不胜感激。。。提前感谢您可以检查
\uuuuu卸载\uuuuu
定义,以确定您是否处于卸载程序代码中:
!include StrFunc.nsh
${StrLoc}
${UnStrLoc}
!macro testmacro
!ifdef __UNINSTALL__
!define /ReDef MyUn "un"
!else
!define /ReDef MyUn ""
!endif
StrCpy $R2 "3654321"
${${MyUn}StrLoc} $R1 "$R2" "365" ">"
DetailPrint $R1
!macroend
Section
!insertmacro testmacro
Goto +2
WriteUninstaller $Temp\Un.exe
SectionEnd
Section Uninstall
!insertmacro testmacro
SectionEnd
这并不理想,我将看看是否可以让StrFunc在下一个版本中使用CallArtificialFunction