0

我为我的 java 项目创建了 nsi 文件。我创建了一个文本框并作为默认值。我的问题是运行 exe 文件,它显示带有默认值的文本框。如果用户想要修改文本框中应该写入的值在属性文件中。我尝试了以下行代码

 InstallOptions::dialog "$PLUGINSDIR\sample.ini"
    ReadINIStr $0 "$PLUGINSDIR\sample.ini" "Field 1" State
    ${ConfigWrite} "$INSTDIR\resource\conf.properties" "AGENT.HOST" "=$0" $R0

但是修改后的值会在属性文件中受到影响。我不知道为什么没有反映?谁能帮我?

4

1 回答 1

0
!include LogicLib.nsh
!include TextFunc.nsh

Function pageConfig
InitPluginsDir

# For this example I generate the page directly with the precompiler, you probably want to use a real .ini file.
!tempfile SRCINI
!appendfile "${SRCINI}" "[Settings]$\nNumFields=1$\n"
!appendfile "${SRCINI}" "[Field 1]$\n"
!appendfile "${SRCINI}" "Type=Text$\n"
!appendfile "${SRCINI}" "Left=10$\nRight=100$\nTop=10$\nBottom=24"
File "/oname=$PluginsDir\cfgpage.ini" "${SRCINI}"
!delfile "${SRCINI}"

ClearErrors
${ConfigRead} "$INSTDIR\resource\conf.properties" "AGENT.HOST=" $0
${If} ${Errors}
    StrCpy $0 "DefaultHost.com"
${EndIf}
WriteIniStr "$PluginsDir\cfgpage.ini" "Field 1" "State" $0

InstallOptions::dialog "$PluginsDir\cfgpage.ini"
Pop $0
FunctionEnd

Function pageLeaveConfig
ReadINIStr $0 "$PluginsDir\cfgpage.ini" "Field 1" State
${If} $0 == ""
    MessageBox mb_iconstop "Please provide a host..."
    Abort
${EndIf}
${ConfigWrite} "$INSTDIR\resource\conf.properties" "AGENT.HOST=" "$0" $1
FunctionEnd


Page custom pageConfig pageLeaveConfig
于 2012-09-20T15:57:29.500 回答