Check installation path for spaces and special symbol in Inno Setup

Viewed 109

I cannot find a solution for checking the user selected path to be without any spaces or special characters.

Can you help me?

1 Answers

You can check for space like this:

[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


You may consider using SuppressibleMsgBox function:
What does it mean that message boxes are being suppressed in Inno Setup?

Related