向用户询问NSIS中的其他目录位置

msd*_*d_2 3 nsis

我有一个NSIS脚本,要求用户提供安装目录,但我想在新页面上向用户询问一个临时目录。有没有一种方法可以使用nsDialogs添加新页面,它为例如

C:\temp
Run Code Online (Sandbox Code Playgroud)

并且还允许他们选择其他目录,然后将所选目录的值存储在变量中

Sek*_*eki 5

如果只需要一个类似于安装目录页面的对话框,则无需自己创建对话框:您只需调用MUI_PAGE_DIRECTORY两次即可。从现有设置中获取的示例:

!insertmacro MUI_PAGE_DIRECTORY ; <= it will store the selected directory into $INSTDIR

;second directory selection
!define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install the database."
!define MUI_DIRECTORYPAGE_TEXT_TOP "The installer will install the database(s) in the following folder. To install in a differenct folder, click Browse and select another folder. Click Next to continue."
!define MUI_DIRECTORYPAGE_VARIABLE $DbInstDir ; <= the other directory will be stored into that variable
!insertmacro MUI_PAGE_DIRECTORY
Run Code Online (Sandbox Code Playgroud)

如果仅在某些情况下需要显示第二个目录选择,则可以使用以下命令向第二个页面添加回调

!define MUI_PAGE_CUSTOMFUNCTION_PRE some_custom_function
Run Code Online (Sandbox Code Playgroud)

在该回调中,测试是否需要显示目录选择。如果没有,则呼叫Abort将跳过该页面。