Inno Setup:验证 {app} 路径不包含空格

sce*_*nox 2 inno-setup

是否可以检查目标安装目录路径是否有空格?如果它包含一个空格,则会出现一条消息并且安装不应该。

我知道,对于任何工具来说,空格都不应该成为问题,但是我们正在使用一些较旧的工具,当路径中有空格时这些工具将无法运行,并且改变这种行为会付出太多努力。

另一种解决方案:用户可以只选择驱动器号。这可能吗?

TLa*_*ama 6

如何检查所选目录是否包含名称中的空格,如果是,则显示消息框并禁止安装向导继续?

以下脚本检查所选目录中的空格,如果该目录包含空格,则会显示一个消息框并将用户保留在目录选择页面上。当用户要通过单击下一步按钮离开目录选择页面时执行此操作:

[Code]

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  { if we're on the directory selection page and the value returned by }
  { the WizardDirValue function contains at least one space, then... }
  if (CurPageID = wpSelectDir) and (Pos(' ', WizardDirValue) > 0) then
  begin
    Result := False;
    MsgBox('Target installation directory cannot contain spaces. ' +
      'Choose a different one.', mbError, MB_OK);
  end;
end;
Run Code Online (Sandbox Code Playgroud)