NSIS:访问自定义页面组合框的值?

NSIS:访问自定义页面组合框的值?,nsis,custom-pages,Nsis,Custom Pages,我已经使用ini文件向NSIS安装程序添加了自定义页面,下面是一个代码 . . . ; Welcome page !insertmacro MUI_PAGE_WELCOME Page custom customPage "" ": custom page" . . . Function customPage GetTempFileName $R0 File /oname=$R0 customPage.ini InstallOptions::dialog

我已经使用ini文件向NSIS安装程序添加了自定义页面,下面是一个代码

.
.
.

    ; 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
.
.
.
这是一个customPage.ini文件

; 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

我想使用NSIS脚本动态设置combobox的值,如何在NSIS中访问combobox?

我手头没有代码,但基本上您要做的是在提取完ini文件后,但在运行
InstallOptions:dialog

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


请注意,在代码中,您没有使用链接网页中显示的InstallOptions宏。相反,您正在手动执行所有操作。通常,InstallOptions宏将自定义页面ini文件提取到插件目录。这意味着我的代码片段可能无法工作,因为您没有遵循通常的模式。因此,如果上述方法不起作用,请尝试使用WriteINI。但是概念是一样的,在提取ini文件之后,但在显示它之前,将值写入ini文件。

就像Aaron说的,使用GetTempFileName是愚蠢的,$pluginsdir是放置它的最佳位置,因为它对您来说是自动删除的。这太棒了!不过,要更改ListItems中的选项,您需要在代码段中将“State”更改为“ListItems”