Press "Enter" to skip to content

How to check and download Ghostscript with Inno Setup

Francesco Mondello 0

As you may know, Inno Setup is one of the best Windows-based solutions to make professional installers for your software.

Since I’m going to release a new version of Converseen and it requires Ghostscript as external resource to manage PDF files, I needed to find an escamotage to notify the user, through the setup program, that the Ghostscript package have to be installed in order to let Converseen working properly.

Inno Setup allows the user to code some routines using the Delphi (pascal) programming language so I’ve written a little code that checks if Ghostscript is installed in the system  (reading the registry key HKEY_CURRENT_USER\SOFTWARE\GPL Ghostscript) and, in negative case, it queries the user that the external package have to be installed through a yes/no message box; if the user presses the yes button, the setup program will open the Ghostscript download page.

Here is the code snippet to do this work. Obviusly you can adapt it on your needs.

[delphi]

[Code]
function gsInstalled(): Boolean;
begin
if RegKeyExists(HKEY_CURRENT_USER, ‘SOFTWARE\GPL Ghostscript’) then
begin
Result := true;
end
else
begin
Result := false;
end
end;

procedure installGs();
var
ErrCode: integer;
begin
if (msgbox(‘In order to enable Converseen to manage PDF files you have to download and install Ghostscript. Do you want to download it now?’, mbConfirmation, MB_YESNO) = IDYES) then
begin
ShellExec(‘open’, ‘http://www.ghostscript.com/download/gsdnld.html’, ”, ”, SW_SHOW, ewNoWait, ErrCode);
end
end;

procedure CurPageChanged(CurPageID: Integer);
var
gsIsInstalled : boolean;
begin
if CurPageID = wpFinished then
begin
gsIsInstalled := gsInstalled();

if gsIsInstalled = false then
installGs();
end
end;

[/delphi]

Comments are closed.