我正在编写一个脚本,安装我的电子制造的应用程序,到目前为止一切似乎都正常。但是,有一个问题,我可以添加新的自定义页面,但它是在安装之前添加的。这是一个问题,因为此页面包含两个用户必须填写的输入字段,然后提供的数据存储在安装应用程序的目录中。但由于在这个步骤之后安装了应用程序,所以目录会被覆盖,文件也会消失。这是代码:
!include nsDialogs.nsh
!include LogicLib.nsh
XPStyle on
Var Dialog
Var UserLabel
Var UserText
Var UserState
Var PassLabel
Var PassText
Var PassState
Page custom nsDialogsPage nsDialogsPageLeave
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Username:"
Pop $UserLabel
${NSD_CreateText} 0 13u 100% 12u $UserState
Pop $UserText
${NSD_CreateLabel} 0 39u 100% 12u "Password:"
Pop $PassLabel
${NSD_CreatePassword} 0 52u 100% 12u $PassState
Pop $PassText
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetText} $UserText $UserState
${NSD_GetText} $PassText $PassState
${If} $UserState == ""
MessageBox MB_OK "Username is missing."
Abort
${EndIf}
${If} $PassState == ""
MessageBox MB_OK "Password is missing."
Abort
${EndIf}
StrCpy $1 $UserState
StrCpy $2 $PassState
FileOpen $9 $INSTDIR\credentials.txt w
FileWrite $9 "$1:$2"
FileClose $9
SetFileAttributes $INSTDIR\credentials.txt HIDDEN|READONLY
FunctionEnd
Section
SectionEnd
所以,是的,最好是在安装之后,而不是之前有这个页面。谢谢你的指点,我对NSI完全陌生,所以我不知道该怎么做。