Load files from a directory into InstallOptions drop down

From NSIS Wiki

Author: Dick4 (talk, contrib)


Description

I take no credit for this code, as it was all written by Sunjammer and some help from Kichik. I just thought others might find it useful.

Anyway, it loads the contents of a directory into a drop down list on a custom InstallOptions page. Useful if you want to modify or work with certain files from within NSIS.

The Function

; 
Function GetFiles
  Exch $5
  FindFirst $2 $1 $5\Path\*.*
  StrCpy $9 ""
  StrCmp $2 "" error
  again:
  StrCmp $1 "" done
  StrCmp $9 "" 0 append
  StrCpy $9 $1
  Goto readnext
  append:
  StrCpy $9 "$9|$1"
  readnext:
  FindNext $2 $1
  Goto again
  done:
  FindClose $2
  ; now write to the ini file
  !insertmacro MUI_INSTALLOPTIONS_WRITE "Options.ini" "Field 2" "ListItems" $9
  DetailPrint $9
  goto finished
  error:
  ; hmmm
  finished:
FunctionEnd

It basically creates the list with the pipe's between each file, then writes it to the install options .ini file.

Personal tools
donate