如何使用NSIS脚本更改文本框值?

时间:2013-09-23 06:45:22

标签: nsis

我是NSIS Script新手并创建安装程序。

在我的页面中有一个文本框。加载文本框的页面显示从一个文本文件中读取文本的值。我想知道如何使用NSIS Scripts。需要代码示例...

1 个答案:

答案 0 :(得分:0)

Function .onInit
InitPluginsDir
FileOpen $0 "$pluginsdir\text.txt" w ; Normally the text file would come from a File command
FileWrite $0 "Hello World$\r$\nfrom$\r$\nNSIS$\r$\n" ; Add some dummy text
FileClose $0
FunctionEnd

Page Custom MyCustomPageInit
Page InstFiles

Var TxtCtl

!include nsDialogs.nsh
!include LogicLib.nsh

Function MyCustomPageInit
nsDialogs::Create 1018
Pop $0

!define MYMULTILINEEDIT_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_MULTILINE}|${ES_READONLY}
nsDialogs::CreateControl EDIT ${MYMULTILINEEDIT_STYLE} ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE} 5% 10u 90% 50% ""
Pop $TxtCtl

FileOpen $0 "$pluginsdir\text.txt" r
loop:
    FileRead $0 $1 ; Read a line
    IfErrors eof
    SendMessage $TxtCtl ${EM_REPLACESEL} 0 "STR:$1$\n"
    Goto loop
eof:
FileClose $0

nsDialogs::Show
FunctionEnd