NSIS 检查安装位置是否为空

NSIS to check installation location is empty or not

如何添加关于显示安装位置覆盖对话框的功能。

如果用户已经安装了该软件,并且他正试图在同一位置重新安装该软件,那么我想显示是否需要覆盖的信息?

我使用了下面的功能,但它是在打开位置页面之前调用的。

Function .onVerifyInstDirIfFileExists "$INSTDIR\temp.xls" PathGood
PathGood:
    MessageBox MB_OKCANCEL "Do you want to overwrite the location with new installer ?" IDOK lbl_ok IDCANCEL lbl_cancel
    lbl_ok:

    lbl_cancel:
    Quit
FunctionEnd 

.onVerifyInstDir 用于禁用下一步按钮,不应显示 UI:

This code will be called every time the user changes the install directory, so it shouldn't do anything crazy with MessageBox or the like. If this function calls Abort, the installation path in $INSTDIR is deemed invalid.

如果要显示消息,则必须改用页面离开回调:

!include LogicLib.nsh

Function MyDirLeave
${If} ${FileExists} "$INSTDIR\temp.xls"
    MessageBox MB_OKCANCEL "Do you want to overwrite the location with new installer?" IDOK +2
    Abort ; Stay on the current page
${EndIf}
FunctionEnd

Page Directory "" "" MyDirLeave
Page InstFiles