inno-setup

Check if drive is connected in Inno Setup


I need to know if a specific drive exists.

My application will install in two different drives, for example: drive F and G.

[Setup]
DefaultDirName=F:\Test\

[Dirs]
Name: G:\Test\storage;

If drive F does not exists Inno Setup show a message about it. But if drive G does not exist the installer stops working. I need warn user to connect the drive G before continuing.


Solution

  • Use DirExists function from InitializeSetup event function:

    function InitializeSetup(): Boolean;
    begin
      while not DirExists('F:\') do
      begin
        MsgBox('Connect F:\ drive.', mbInformation, MB_OK); 
      end;
      Result := True;
    end;