Вы можете сделать это с пользовательской страницей:
!include nsDialogs.nsh
!include FileFunc.nsh
Page Custom MyPageCreate MyPageLeave
Var PhpPath
Function MyPageLeave
${NSD_GetText} $PhpPath $0
${GetFileName} $0 $1
${IfNot} ${FileExists} $0
${OrIf} $1 != "php.exe"
MessageBox mb_iconstop "You must locate php.exe to continue!"
Abort
${Else}
#php path is in $0, do something with it...
${EndIf}
FunctionEnd
Function MyPageComDlgSelectPHP
Pop $0
${NSD_GetText} $PhpPath $0
nsDialogs::SelectFileDialog open $0 "php.exe|php.exe"
Pop $0
${If} $0 != ""
${NSD_SetText} $PhpPath $0
${EndIf}
FunctionEnd
Function MyPageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateText} 0 5u -25u 13u "$ProgramFiles\PHP\php.exe"
Pop $PhpPath
${NSD_CreateBrowseButton} -23u 4u 20u 15u "..."
Pop $0
${NSD_OnClick} $0 MyPageComDlgSelectPHP
nsDialogs::Show
FunctionEnd
или вы можете использовать страницу каталога:
!include LogicLib.nsh
Var PhpPath
Function .onInit
StrCpy $PhpPath "$ProgramFiles\PHP" ; Default (You could probably do better by checking the registry)
FunctionEnd
PageEx Directory
DirVar $PhpPath
DirVerify leave
PageCallbacks "" PhpPageShow PhpPageLeave
DirText "Select PHP folder" "PHP Folder" "" "Select PHP folder"
PageExEnd
Function PhpPageShow
;Hide space texts
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $1 $0 0x3FF
ShowWindow $1 0
GetDlgItem $1 $0 0x400
ShowWindow $1 0
FunctionEnd
Function PhpPageLeave
GetInstDirError $0
${If} $0 <> 0
${OrIfNot} ${FileExists} "$PhpPath\php.exe"
MessageBox mb_iconstop "You must locate the php folder to continue!"
Abort
${EndIf}
FunctionEnd