Inno Setup: How to check if JRE is present and prompt to download if not?

NullPointerException :

I'm developing the installer for a Java 64 bit application with Inno Setup.

It is possible with Inno Setup to check if Java 64 bit is present in the computer and if not to display the user a link for download Java 64 bit?

What should I add to Inno Setup script it to achieve that behaviour?

Elarbi Mohamed Aymen :

Below you can find a script that could check if JRE is installed then prompt a message for the user I used this Stack Overflow post as reference: How do I install a JRE from an Inno Setup?

[Code]
{ Script to check if a JRE is installed }

function InitializeSetup(): Boolean;
var
  ErrorCode: Integer;
  JavaVer: string;
begin
    RegQueryStringValue(
        HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', JavaVer);
    Result := (Length(JavaVer) > 0);
    if not Result then
    begin
        if MsgBox('YOUR MESSAGE GOES HERE', mbConfirmation, MB_YESNO) = idYes then
        begin
            ShellExec(
              'open', 'https://www.java.com/en/download/manual.jsp#win',
              '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
        end;
    end;
end;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=101747&siteId=1