2012-09-20 70 views
0

我已經爲我的java項目創建了nsi文件。我創建了一個文本框並給出了默認值。我的問題是運行exe文件時它顯示的文本框具有默認值。如果用戶要修改應當在物業file.I來寫嘗試以下幾行代碼使用NSIS腳本將屬性值移動到文本框中

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

但修改後的值將物業file.I影響不知道爲什麼這個狀態並沒有體現在文本框中的值?誰能幫我?

回答

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 
+0

@sekt thanks.while安裝我有AGENT.HOST修正值value.but安裝後,我看到了默認值only.modified值尚未reflected.i不知道ÿ? – Ami

+0

@seki thanks.I已經使用Exec命令,那麼它的工作很好,謝謝你的支持。 – Ami

相關問題