Archive: Rich text file not display in License page


Rich text file not display in License page
Hi all,

Please see code below.

I am using the addLicense from the forum to display EULA file according to user's selection.
The problem I am having is that: it always display the default file (en-US).

I know for a fact that it went to the right country comparison in the If/ElseIf statements by using MessageBox to verify.

Seem like it couldn't find the file in the statement "FileOpen $0 $EXEDIR\${LIC_NAME1} r".

Any idea? Thanks for your help!

-----------------------------

!define LIC_NAME1 "..\doc\eula\da-DK.rtf"
!define LIC_NAME2 "..\doc\eula\de-DE.rtf"
!define LIC_NAME3 "..\doc\eula\el-GR.rtf"

; License page
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_PAGE_CUSTOMFUNCTION_SHOW addLicense
!insertmacro MUI_PAGE_LICENSE "..\doc\eula\en-US.rtf"

LangString Denmark ${LANG_FRENCH} "Denmark"
LangString Germany ${LANG_FRENCH} "Germany"
LangString Greece ${LANG_FRENCH} "Greece"

Function addLicense
ClearErrors

; Display EULA base on user's selection
${If} $Country S== $(Denmark)
FileOpen $0 $EXEDIR\${LIC_NAME1} r
${ElseIf} $Country S== $(Germany)
FileOpen $0 $EXEDIR\${LIC_NAME2} r
${ElseIf} $Country S== $(Greece)
FileOpen $0 $EXEDIR\${LIC_NAME3} r

IfErrors exit
System::Call 'kernel32::GetFileSize(i r0, i 0) i .r1'
IntOp $1 $1 + 1 ; for terminating zero
System::Alloc $1
Pop $2
System::Call 'kernel32::ReadFile(i r0, i r2, i r1, *i .r3, i 0)'
FileClose $0
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1000
SendMessage $0 ${EM_SETLIMITTEXT} $1 0
SendMessage $0 ${WM_SETTEXT} 0 $2
System::Free $2

exit:

FunctionEnd


Re: Rich text file not display in License page
Again, you're mixing up "compile-time" files and "runtime" files.

!insertmacro MUI_PAGE_LICENSE "..\doc\eula\en-US.rtf"
This refers to a file at compile-time. The path is relative to the NSI script file. The file will be embedded inside the installer and automatically extracted as needed


!define LIC_NAME1 "..\doc\eula\da-DK.rtf"
...
FileOpen $0 $EXEDIR\${LIC_NAME1} r
This refers to a file accessed at runtime. The path is relative to $EXEDIR = the installer EXE directory. The file must already exist on the target computer which runs the installer.


I think what you want to do is embed several license files in the installer, extract them at runtime and then choose the adequate one:

InitPluginsDir
SetOutPath "$PLUGINSDIR" ; let's use a temporary folder
File /r "..\doc\eula" ; this embed all the files in that directory and will extract them at runtime
${If} $Country S== $(Denmark)
FileOpen $0 "$PLUGINSDIR\eula\da-DK.rtf" r
...

Thanks Wizou! I need to pay attention to compile time and runtime stuff then.

So, when I use this:
!insertmacro MUI_PAGE_LICENSE "..\doc\eula\en-US.rtf"

it will embed the file?

And, when I use this:
!define LIC_NAME1 "..\doc\eula\da-DK.rtf"

It only points that file's location, and not embed the file?


Yes, it's because !insertmacro MUI_PAGE_LICENSE is a MUI macro which relies on instructions LicenseData and LicenseLangString, and these instructions embed the given files into the installer, just like the File instruction.

If I'm correct, outside these 3 specific instructions, all other paths encountered in NSIS scripts are just pointing to location on target PC at run-time and do not lead to a file being embedded into the installer..


Thanks Wizou!