如何在安装程序中使文本字段为可选?

时间:2019-07-15 07:29:09

标签: nsis

我是nsis安装程序的新手。我的ini文件中有一个文本字段。在我的安装程序中,如果未在该字段中输入任何数据,它将不会移至其他步骤。我需要将该文本字段设置为可选字段。如何在可选字段中设置该字段?

请帮助我吗?

[Settings]
    NumFields=4

    [Field 1]
    Type=Label
    Text="First name"
    Left=0
    Right=54
    Top=67
    Bottom=79

    [Field 2]
    Type=Text
    Left=55
    Right=125
    Top=65
    Bottom=77
    MinLen=1

    [Field 3]
    Type=Label
    Text="Last Name"
    Left=0
    Right=54
    Top=83
    Bottom=95

    [Field 4]
    Type=Text
    Left=55
    Right=125
    Top=113
    Bottom=125
    MinLen=1

使字段4为可选。

1 个答案:

答案 0 :(得分:0)

Outfile "Optional.exe"
Name "Make Field Optional"
Brandingtext "Created by Kanwar Adnan"

Page Custom Page MakeFieldOptional

Section
sectionEnd

Function .oninit
initpluginsdir
file /oname=$PLUGINSDIR\dlg.ini gmail.ini
FunctionEnd

Function Page
installoptions::dialog "$PLUGINSDIR\dlg.ini"
FunctionEnd

Function MakeFieldOptional
ReadINIStr $0 "$PLUGINSDIR\dlg.ini" "Field 4" "state"
StrCmp $0 "" 0 +3
MessageBox MB_ICONSTOP "Please enter something in field 4"
abort
FunctionEnd