Archive: proper 64-bit and 32-bit handling?


proper 64-bit and 32-bit handling?
I am trying to make an installer that handles 64-bit and 32-bit properly. This includes $PROGRAMFILES and $PROGRAMFILES64.

I had tried

!include "MUI2.nsh"
!include "logiclib.nsh"
!include "x64.nsh"
!include "shortcut.nsh" ;mine


;--------------------------------
;General

;Name and file
Name "Thunderbird Mail Split GUI"
OutFile "${PRODUCT_NAME}-${VERSION_STRING}-setup.exe"

;Default installation folder
; InstallDir "$LOCALAPPDATA\${PRODUCT_NAME}"

${If} ${RunningX64}
InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}"
${Else}
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
${EndIf}

;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""

;Request application privileges for Windows Vista
RequestExecutionLevel admin


!define MUI_ABORTWARNING
Function .onInit
#prevent multiple instances of the installer running
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${PRODUCT_NAME}") i .r1 ?e'
Pop $R0

StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort

GetDlgItem $0 $HWNDPARENT 1
CreateFont $1 "$(^Font)" "14" "700"
;culprit. worked in older versions. what do I do now? got this from the forums.
; CreateFont $HEADLINE_FONT "$(^Font)" "14" "700"
InitPluginsDir
${If} ${RunningX64}
SetOutPath "$PROGRAMFILES64\${PRODUCT_NAME}"
${Else}
SetOutPath "$PROGRAMFILES\${PRODUCT_NAME}"
${EndIf}



SetShellVarContext all

FunctionEnd



but this doesn't work, bails at first ${If}.
at the very least, I need a solution to this problem of how to handle 32 and 64-bit executables properly.


I am also looking for a REAL usable installer template I can base my stuff off of. something with 64-bit and 32-bit support, don't really need multiple languages, though that would be useful, settable program version and program name, title via !define and process kill.


I think a construct like "${If} ${RunningX64}" will only work with install-time instructions, i.e. in a Section or Function.

But "InstallDir" is global installer attribute, evaluated at compile-time.

For obvious reasons you can't detect the architecture of the customer's machine at compile-time!

Try something like:

Function .onInit
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_NAME}"
${EndIf}
FunctionEnd

ok, this technique alone is not working in win7. I heard you have to use this in conjunction with SetRegView 64 or 32 to do some more correct x64 handling. but I am sure there is more than this, because it's still extracting to c:\program files\subdir\ instead of to where I told it to, which is in d:\pro\subdir\ - any ideas?
I am trying to install to win7ult64 and also to winxppro32.


here is my current script set. shortcut.nsh is only for making .lnk and .url files. setup.nsi is the main script.
the installer ends up in d:\prog\uritoxml\ but like I said the rest of the program stuff ends up in c:\program files\uritoxml\