简体   繁体   English

如何在nsis脚本中使用regasm在同一宏中注册两个dll:s?

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

I am trying to register two dll:s using a macro that takes these parameters: 我正在尝试使用带有以下参数的宏来注册两个dll:s:

!macro RegisterWithRegAsm flag executable typeLib !宏RegisterWithRegAsm标志可执行文件typeLib

I call the macro like this: 我这样称呼宏:

!insertmacro RegisterWithRegAsm "" "Dll1.dll" "Dll1.tlb" !insertmacro RegisterWithRegAsm "" "Dll2.dll" "Dll2.tlb" !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 : 问题是我只能在第二次NSIS抱怨我已经声明了标签的情况下一次运行宏:

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

How can I move this label (and the u_inst_) outside of the macro so I can use it more than once? 如何将该标签(和u_inst_)移到宏之外,以便可以多次使用?

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. 我已经看过nsis网页,但是找不到对多个dll处理的引用。

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. util.nsh中的CallArtificialFunction内容是一个帮助程序宏,可以轻松地将宏转换为函数。

!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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM