How can I register two dll:s in with the same macro using regasm in a nsis script?

StackOverflow https://stackoverflow.com/questions/7190393

  •  12-01-2021
  •  | 
  •  

سؤال

I am trying to register two dll:s using a macro that takes these parameters:

!macro RegisterWithRegAsm flag executable typeLib

I call the macro like this:

!insertmacro RegisterWithRegAsm "" "Dll1.dll" "Dll1.tlb" !insertmacro RegisterWithRegAsm "" "Dll2.dll" "Dll2.tlb"

THe problem is I can only run the macro one time cause the second time the NSIS complains that I have already declared a label :

inst__: StrCpy $R1 '$R0${DOT_NET_VERSION_2_SP2}\RegAsm.exe "$INSTDIR\${APP_NAME_COMPACT}\${executable}" /codebase /tlb:"$INSTDIR\${APP_NAME_COMPACT}\${typeLib}" /silent'

How can I move this label (and the u_inst_) outside of the macro so I can use it more than once?

ANyone know of a good site for reference? I have looked at the nsis web page but can't find references to multiple dll handling.

THanks for any ideas!

هل كانت مفيدة؟

المحلول

One solution is to make the label unique with a prefix:

!macro UselessExample string
!define UselessExample_lbl "UselessExample_${__LINE__}" ;prefixing with the macro name is a good way to avoid conflicts
Goto ${UselessExample_lbl}pointlessjump
DetailPrint "Hello?"
${UselessExample_lbl}pointlessjump:
DetailPrint "${string}"
!undef UselessExample_lbl
!macroend

Section
!insertmacro UselessExample "Hello1"
!insertmacro UselessExample "Hello2"
SectionEnd

Or if you are creating a utility function that will be called in many places it is usually better to create a function. The CallArtificialFunction stuff in util.nsh is a helper macro that makes it easy to turn a macro into a function.

!include util.nsh

!macro UselessExample string
Push "${string}"
${CallArtificialFunction} UselessExampleWorker
!macroend
!macro UselessExampleWorker
Pop $0
DetailPrint $0
!macroend

Section
!insertmacro UselessExample "Hello1"
!insertmacro UselessExample "Hello2"
SectionEnd
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top