NSIS Installer - Displaying different licences

主宰稳场 提交于 2020-01-01 10:16:39

问题


I'm trying to modify an existing NSIS install script to allow for different licence files to be presented to the user depending on whether they are a new or existing user. I have pre-existing code which detects an existing install in the .onInit section.

However I'm running into bumps trying to use the NSIS provided licence screen e.g.

!InsertMacro MUI_PAGE_LICENSE Content\Licence.rtf

I would like to be able to choose between Licence and Licence2.rtf (though they'll be renamed something representative in the final version).

I've tried using selectable sections calling functions which nest the !insertmacro but that doesn't work because it needs to be in the base level of the script.

I can't change the parameter to be runtime definable because it needs to know what the file is at compile time to build it into the installer.

I know I can roll my own custom page called from a function and do it that way but I was wondering if anyone had got the NSIS installer working with using the MUI_PAGE_LICENSE and different licences.

Thanks


回答1:


There are two ways to skin this cat:

  • Use 2 license pages and skip one of them
  • Load the license file manually at run-time

Two pages:

!define MUI_PAGE_CUSTOMFUNCTION_PRE skip1
!InsertMacro MUI_PAGE_LICENSE Content\Licence.rtf
!define MUI_PAGE_CUSTOMFUNCTION_PRE skip2
!InsertMacro MUI_PAGE_LICENSE Content\Licence2.rtf
#You need two functions skip1 and skip2, they should call `abort` to skip based on some state you determine at run-time

Manual load:

There is a plugin that does this for you (Not sure if it supports RTF)

I wrote some code that does this using the system plugin, you can find that on the nsis forum. To use that code, you would include your license files with normal File commands and extract the one you want to $pluginsdir and load it in the license page's show callback function.




回答2:


There is an easier way. I use this code:

!insertmacro MUI_PAGE_LICENSE $(MUILicense)

Also, you have to put in your code lines like this:

LicenseLangString MUILicense ${LANG_POLISH} "SomeDirectory\licencja_pl.txt"
LicenseLangString MUILicense ${LANG_ENGLISH} "SomeDirectory\license_en.txt"

They don't have to appear before inserting license macro. In my code I defined them just below and it works fine.



来源:https://stackoverflow.com/questions/2434344/nsis-installer-displaying-different-licences

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!