且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Inno Setup - 检查目标中是否存在文件,否则不会中止安装

更新时间:2023-11-28 09:44:58

在用户选择正确的文件夹之前不要让他们继续.

Just don't let the user proceed until they pick the correct folder.

function NextButtonClick(PageId: Integer): Boolean;
begin
    Result := True;
    if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}yourapp.exe')) then begin
        MsgBox('YourApp does not seem to be installed in that folder.  Please select the correct folder.', mbError, MB_OK);
        Result := False;
        exit;
    end;
end;

当然,尝试自动为他们选择正确的文件夹也是一个好主意,例如.通过从注册表中检索正确的位置.

Of course, it's also a good idea to try to automatically pick the correct folder for them, eg. by retrieving the correct location out of the registry.