Archive: Problems with 64-bit


Problems with 64-bit
Hello,

I'am trying to create an installer with NSIS (2.23) that will install a software on Windows XP, Windows XP 64-bit, Vista and Vista 64-bit.

I have problems with x64.nsh, here is my tests:


!include "LogicLib.nsh"
!include "x64.nsh"

OutFile "nsis_test.exe"
InstallDir "$PROGRAMFILES\Company\Product"

Section
${If} ${RunningX64}
DetailPrint "Running X64=1"
${Else}
DetailPrint "Running X64=0"
${Endif}

DetailPrint "=== Default ==="
DetailPrint "SYSDIR=$SYSDIR"
DetailPrint "INSTDIR=$INSTDIR"
DetailPrint "PROGRAMFILES=$PROGRAMFILES"

DetailPrint "=== After Disable ==="
${DisableX64FSRedirection}

DetailPrint "SYSDIR=$SYSDIR"
DetailPrint "INSTDIR=$INSTDIR"
DetailPrint "PROGRAMFILES=$PROGRAMFILES"

DetailPrint "=== After Enable ==="
${EnableX64FSRedirection}

DetailPrint "SYSDIR=$SYSDIR"
DetailPrint "INSTDIR=$INSTDIR"
DetailPrint "PROGRAMFILES=$PROGRAMFILES"
SectionEnd


After compiling and running the resulting test_nsis.exe, I obtain this result on 64-bit plateforms :


Running X64=1
=== Default ===
SYSDIR=C:\WINDOWS\system32
INSTDIR=C:\Program Files (x86)\Company\Product
PROGRAMFILES=C:\Program Files (x86)
=== After Disable ===
SYSDIR=C:\WINDOWS\system32
INSTDIR=C:\Program Files (x86)\Company\Product
PROGRAMFILES=C:\Program Files (x86)
=== After Enable ===
SYSDIR=C:\WINDOWS\system32
INSTDIR=C:\Program Files (x86)\Company\Product
PROGRAMFILES=C:\Program Files (x86)
Completed


I would have expected


Running X64=1
=== Default ===
SYSDIR=C:\WINDOWS\SysWOW64
INSTDIR=C:\Program Files (x86)\Company\Product
PROGRAMFILES=C:\Program Files (x86)
=== After Disable ===
SYSDIR=C:\WINDOWS\system32
INSTDIR=C:\Program Files\Company\Product
PROGRAMFILES=C:\Program Files
=== After Enable ===
SYSDIR=C:\WINDOWS\SysWOW64
INSTDIR=C:\Program Files (x86)\Company\Product
PROGRAMFILES=C:\Program Files (x86)
Completed


As test_nsis.exe is a 32-bit executable running on a 64-bit OS.

Am I wrong ?

If I am wrong what is the solution to get PROGRAMFILES with the right path if I need to install 32-bit executables, and the 64-bit executables ??

Thank you very much for any answer.

After finding

http://nsis.cvs.sourceforge.net/nsis...?r1=1.4&r2=1.5

I changed my test script to :


!include "LogicLib.nsh"
!include "x64.nsh"

OutFile "nsis_test.exe"
InstallDir "$PROGRAMFILES\Company\Product"

Section
${If} ${RunningX64}
DetailPrint "Running X64=1"
${Else}
DetailPrint "Running X64=0"
${Endif}

DetailPrint "=== Default ==="
SetOutPath "$SYSDIR"
File /oname=SYSDIR_1.tmp test.nsi
SetOutPath "$INSTDIR"
File /oname=INSTDIR_1.tmp test.nsi
SetOutPath "$PROGRAMFILES"
File /oname=PROGRAMFILES_1.tmp test.nsi

${DisableX64FSRedirection}
DetailPrint "=== After Disable ==="
SetOutPath "$SYSDIR"
File /oname=SYSDIR_2.tmp test.nsi
SetOutPath "$INSTDIR"
File /oname=INSTDIR_2.tmp test.nsi
SetOutPath "$PROGRAMFILES"
File /oname=PROGRAMFILES_2.tmp test.nsi

${EnableX64FSRedirection}
DetailPrint "=== After Enable ==="
SetOutPath "$SYSDIR"
File /oname=SYSDIR_3.tmp test.nsi
SetOutPath "$INSTDIR"
File /oname=INSTDIR_3.tmp test.nsi
SetOutPath "$PROGRAMFILES"
File /oname=PROGRAMFILES_3.tmp test.nsi
SectionEnd


but all the files are created in the same directories...

$PROGRAMFILES is constant, not variable, and the question is when it is initialized. AFAIK good place to disable redirection and get correct constant value is .onInit. May be you can use %ProgramFiles% later instead of $PROGRAMFILES (not tested).


Originally posted by Takhir
$PROGRAMFILES is constant, not variable, and the question is when it is initialized. AFAIK good place to disable redirection and get correct constant value is .onInit. May be you can use %ProgramFiles% later instead of $PROGRAMFILES (not tested).
Thank you very much, by using dynamic variables, I can install files in the right directories...

Now I have a new problem, accessing the right registry hive!

While reading this forum, I saw a thread about writing system calls to read registry hive in 64-bit and another one about a patch :

http://sourceforge.net/tracker/index...49&atid=373087

Do I have to rewrite all my scripts to use macro for 64-bit registry reading/writing, or can I wait for the inclusion of the pacth ?

For now, you'd have to use the macro. You could make a macro of your own that'd wrap that macro, so once the patch is applied, you only have to change one line of code.