View Single Post
Old 21st May 2020, 21:42   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,310
The example you linked to uses two InstFiles pages which is extra complicated and not really needed in your scenario.

The basics are really simple, just unselect the function in .onInit if you are on a x86 system. A bit more tweaking is required to get the directory pages to display the correct sizes.

PHP Code:
InstallDir "$ProgramFiles\MyApp"

!include LogicLib.nsh
!include x64.nsh
!include Sections.nsh
!include WinMessages.nsh

Var DosboxDir

Page Components
Page Directory MainDirPagePreCallback
PageEx Directory
    PageCallbacks DosBoxDirPagePreCallback
    DirVar $DosboxDir
    Caption 
": DOSBox directory"
PageExEnd
Page InstFiles

Function .onInit
StrCpy $DosboxDir 
"$ProgramFiles\DOSBox" ; Default DOSBox directory
Call ConfigureSectionsForPlatform
FunctionEnd

Section 
-Pre
Call ConfigureSectionsForPlatform 
Restore sections because we changed them for the directory pages
SectionEnd

Section 
"Main Application" SID_MAIN
SectionIn RO
SetOutPath $InstDir
File 
$%windir%\Explorer.exe Dummy file
SectionEnd

Section 
"DOSBox" SID_DOSBOX
SectionIn RO
SetOutPath $DosboxDir
File 
$%windir%\system32\regedit.exe Dummy file
SectionEnd

Function ConfigureSectionsForPlatform
!insertmacro SelectSection ${SID_MAIN}
${If} ${
IsNativeIA32}
    !
insertmacro UnselectSection ${SID_DOSBOX}
${Else}
    !
insertmacro SelectSection ${SID_DOSBOX}
${EndIf}
FunctionEnd

Function MainDirPagePreCallback
Call ConfigureSectionsForPlatform
!insertmacro UnselectSection ${SID_DOSBOX}
${If} ${
IsNativeIA32}
    
GetDlgItem $0 $hWndParent 1
    SendMessage 
$${WM_SETTEXT"" "STR:$(^InstallBtn)" Change the button text if there is no other pages before the InstFiles page
${EndIf}
FunctionEnd

Function DosBoxDirPagePreCallback
${If} ${IsNativeIA32}
    
Abort Skip the page
${EndIf}
Call ConfigureSectionsForPlatform
!insertmacro UnselectSection ${SID_MAIN}
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote