Mrunal February 2016

How to disable Disk Space Warning message in Inno Setup?

I am creating installer using Inno Setup. I have calculated available disk space using function GetSpaceOnDisk. I am displaying error message if available disk space is not enough, and then installer will not continue.

But before my error message displays, Inno Setup Disk space warning is shown with Yes/No option. How can I disable this warning?

Answers


Martin Prikryl February 2016

You cannot disable the check, nor change the buttons.


What you can do, is to revert a meaning of a question in the message by overriding the default text using [Messages] section, to say something like:

Do you want to cancel installation?

If the user presses No, the installer stays on the Select Destination Location page. If the user presses Yes, the NextButtonClick(wpSelectDir) gets called. There you repeat the check for the disk space (to distinguish the call from a basic scenario, with no warning), and if there's not enough space, you abort the installer forcefully.

[Messages]
DiskSpaceWarning=Setup requires at least %1 KB of free space to install, but the selected drive only has %2 KB available.%n%nDo you want to cancel installation?

[Code]

function NotEnoughSpace: Boolean;
begin
  Result := { Check disk space };
end;

procedure ExitProcess(exitCode:integer);
  external 'ExitProcess@kernel32.dll stdcall';

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpSelectDir then
  begin
    if NotEnoughSpace then
    begin
      ExitProcess(0);
    end; 
  end;
  Result := True;
end;

The ultimate solution is to re-implement the Select Destination Location page. It's not that difficult. It's just one edit box and one button.

Post Status

Asked in February 2016
Viewed 1,243 times
Voted 11
Answered 1 times

Search




Leave an answer