views:

235

answers:

1

I have added custom page to NSIS installer using ini files, here is a 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 a 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 set values of combobox dynamically using NSIS script, how can I access combobox in nsis?

+1  A: 

I don't have code handy but basically what you do is write ini values to that ini file, just after you extract it, but before you run InstallOptions:dialog

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

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

Note that in your code you aren't using the InstallOptions macros like you see in the linked webpage. Instead you are doing everything manually. Normally the InstallOptions macros extract the custom page ini files to the plugins directory. This means my code snippet might not work since you aren't following the usual pattern. 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 just after extracting it, but before displaying it.

AaronLS
Like Aaron says, using GetTempFileName is stupid, $pluginsdir is the best place to put it since it is auto-deleted for you
Anders