代码之家  ›  专栏  ›  技术社区  ›  Xinus

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

  •  2
  • Xinus  · 技术社区  · 15 年前

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

    .
    .
    .
    
        ; 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?

    1 回复  |  直到 15 年前
        1
  •  2
  •   AaronLS    15 年前

    我没有现成的代码,但基本上您要做的就是在提取后,但在运行之前,将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文件提取到plugins目录中。这意味着我的代码片段可能不起作用,因为您没有遵循通常的模式。因此,如果上述方法不起作用,请尝试使用writeini。但是这个概念是相同的,在提取之后,在显示之前,将值写到ini文件中。

    推荐文章