inno setup 自动检测jre

来源:互联网 发布:mac解压软件知乎 编辑:程序博客网 时间:2024/06/04 20:06
 

//开始安装前,进行提示安装jre,这里应该自动找jre,暂时先用手动的。
function InitializeSetup(): Boolean;
var

errorcode:Integer;
setupjre: Boolean;
javaInstalled : Boolean;

begin
  javaInstalled := RegKeyExists(HKLM,'SOFTWARE\JavaSoft\Java Runtime Environment\1.6');
 if JavaInstalled then
   begin
    Result := true;
   end
 else
   begin
     //没有jre
     MsgBox('解压JRE安装包,需要10秒左右,请点击确定继续!', mbConfirmation, MB_OK) ;
      ExtractTemporaryFile(ExtractFileName(ExpandConstant('{tmp}\jre6.exe')));
      ShellExec('open',ExpandConstant('{tmp}\jre6.exe'),'','',SW_SHOW,ewWaitUntilTerminated,errorcode)
      MsgBox(IntToStr(errorcode), mbConfirmation, MB_OK) ;
      if errorcode=0 then
        begin
          Result := true;
        end
      else
        begin
          Result :=false;
        end
     end

  Result := true;