【问题标题】:NSIS: Access values of combo box of custom page?NSIS:访问自定义页面组合框的值?
【发布时间】:2010-05-05 08:48:07
【问题描述】:

我已经使用 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 中的组合框?

【问题讨论】:

    标签: nsis custom-pages


    【解决方案1】:

    我没有手头的代码,但基本上你所做的就是将 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 文件提取到插件目录。这意味着我的代码 sn-p 可能无法正常工作,因为您没有遵循通常的模式。因此,如果上述方法不起作用,请尝试改用 WriteINI。但是概念是一样的,就是在提取出来之后,在显示之前把值写入ini文件。

    【讨论】:

    • 就像 Aaron 说的那样,使用 GetTempFileName 是愚蠢的,$pluginsdir 是放置它的最佳位置,因为它会为您自动删除
    • 这太棒了!但是有一条评论,要更改 ListItems 中的选项,您需要在代码 sn-p 中将“State”更改为“ListItems”
    猜你喜欢
    • 2021-04-21
    • 1970-01-01
    • 2011-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-05
    • 1970-01-01
    相关资源
    最近更新 更多