Old 21st February 2018, 03:07   #1
Senior Member
r2du-soft's Avatar
Join Date: Nov 2013
Location: Iran
Posts: 243
Question select multiple files with dialog open

how can select multiple files in dialog box in nsis?
i try with:


DialogsEx (${OpenBox} "Search for a java files" "java files (*.java)|*.java||" 1 "$EXEDIR" 3 ${VAR_6})

nsDialogs::SelectFileDialog /NOUNLOAD open "" "Java Files|*.java|All Files|*.*"

with that's plugins just can select one file but i want to select multiple files...

after select files i want use this
ExecDos::exec '"$JavaExePatch" "$0"'

to convert *.java files to .class files
r2du-soft is offline   Reply With Quote
Old 22nd February 2018, 18:37   #2
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,658
The Windows open/save dialogs are badly designed and if you want to support a selection of "unlimited" number of files you need 3 separate codepaths in your application, one for 95/98/ME, one for NT4/2000/XP/2003 and one for Vista+ and I'm not going to code all that for you.

Here is a limited version but should be enough for most uses:

PHP Code:
!include LogicLib.nsh
!include Util.nsh
!ifndef IntPtrOp
!define IntPtrOp IntOp
!define NSIS_CHAR_SIZE 1
define OFN_ENABLESIZING 0x00800000
!define OFN_HIDEREADONLY 0x00000004
!define OFN_ALLOWMULTISELECT 0x00000200
!define OFN_FILEMUSTEXIST 0x00001000
!define OFN_EXPLORER 0x00080000
!if "${NSIS_PTR_SIZE}<= 4
!define OPENFILENAME 'i,i,i,i,i,i,i,i,i,i,i,i,i,i,&i2,&i2,i,i,i,i'
error TODO

define MYMULTISELCCH 42000 Hopefully large enoughthere is no way to know how many files the user will select
::Call '*(&t${MYMULTISELCCH})i.s' Allocate OPENFILENAME.lpstrFile buffer
::Call '*(${OPENFILENAME})i.r0' Allocate OPENFILENAME struct
System::Call '*$1(&t${NSIS_MAX_STRLEN} "$InstDir")' Initial path (This is optional)
System::Call 'COMDLG32::GetOpenFileName(ir0)i.r2'
System::Call '*$0(${OPENFILENAME})(,,,,,,,,,,,,,,&i2.r3)'
System::Free $0
${If} $<> 0
::Call "*$1(&t${NSIS_MAX_STRLEN}.r2)" Get directory single file
#IntOp $0 $0 + 1 ; For \0 but should not be required because a directory cannot be chosen as a file
${If} $< $0
      MessageBox mb_ok 
"Single file: $2"
StrCpy $5 0
StrLen $$0
::Call "*$3(&t$0,&t1,&t${NSIS_MAX_STRLEN}.r4)"
!if ${NSIS_CHAR_SIZE} > 1
IntPtrOp} $$+ $0
${IntPtrOp} $$+ ${NSIS_CHAR_SIZE} ; \0
${If} $!= ""
StrCpy $"$2\$4"
IntOp $$1
        MessageBox mb_ok 
"File #$5: $0"
StrCpy $$4
Goto loop
System::Free $

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump