在Inno Setup中检查安装路径是否有空格和特殊符号

问题描述

我找不到解决方案来检查用户选择的路径是否没有空格或特殊字符。

你能帮我吗?

解决方法

您可以像这样检查空间:

[Code]

function NextButtonClick(CurPageID: Integer): Boolean;
var
  Dir: string;
  Msg: string;
begin
  Result := True;
  if CurPageID = wpSelectDir then
  begin
    Dir := WizardForm.DirEdit.Text;
    if Pos(' ',Dir) > 0 then
    begin
      Msg := 'The path cannot contain spaces';
      if WizardSilent then Log(Msg)
        else MsgBox(Msg,mbError,MB_OK);
      Result := False;
    end;
  end;
end;

enter image description here


您可以考虑使用SuppressibleMsgBox function
What does it mean that message boxes are being suppressed in Inno Setup?