NSIS: access values ​​for a custom page combo box?

I have added a custom page to NSIS installer using ini files, here is the code

.
.
.

    ; Welcome page
    !insertmacro MUI_PAGE_WELCOME
    Page custom customPage "" ": custom page"
.
.
.
Function customPage
   GetTempFileName $R0
   File /oname=$R0 customPage.ini
   InstallOptions::dialog $R0
   Pop $R1
   StrCmp $R1 "cancel" done
   StrCmp $R1 "back" done
   StrCmp $R1 "success" done
   error: MessageBox MB_OK|MB_ICONSTOP "InstallOptions error:$\r$\n$R1"
   done:
FunctionEnd
.
.
.

      

Here is the customPage.ini file

; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=2

[Field 1]
Type=Label
Text=Select Version:
Left=4
Right=53
Top=16
Bottom=26

[Field 2]
Type=Combobox
Text=Combobox
ListItems=
Left=53
Right=138
Top=14
Bottom=107

      

I want to dynamically set combobox values ​​using NSIS script, how can I access combobox in nsis?

+2


a source to share


1 answer


I don't have a handy code, but basically you write the ini values ​​to this ini file right after you fetch it, but before running InstallOptions:dialog

!insertmacro INSTALLOPTIONS_WRITE "customPage.ini" "Field 2" "State" "Blah|Value2|Foo|Bar"

      



See: http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html

Please note that in your code you are not using InstallOptions macros as you see in the linked web page. Instead, you do everything by hand. Typically InstallOptions macros will extract custom ini pages to the plugin directory. This means that my code snippet may not work as you are not following the usual patterns. So instead, if the above doesn't work, try using WriteINI instead. But the concept is the same, write the value to the ini file right after extracting it but before displaying it.

+2


a source







All Articles