2

我已经使用 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 脚本动态设置组合框的值,如何访问 nsis 中的组合框?

4

1 回答 1

3

我没有方便的代码,但基本上你所做的就是将 ini 值写入该 ini 文件,就在你提取它之后,但在你运行之前InstallOptions:dialog

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

请参阅: http: //nsis.sourceforge.net/Docs/InstallOptions/Readme.html

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

于 2010-05-05T17:04:38.350 回答