0

我是 NSIS 脚本和创建安装程序的新手。

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

4

1 回答 1

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
于 2013-09-23T17:18:40.920 回答