如何从 TOutPutProgressWizardPage 退出安装,Inno Setup:

发布于 2024-10-12 18:37:43 字数 12053 浏览 3 评论 0原文

我对此问题已经有一段时间了。直到这篇文章之前,我从未真正在网上寻求过帮助。

我已经使用 Inno Setup 编写了一个安装程序。它安装了很多东西,其中之一就是当前版本的 Java 开发工具包。我的问题是我需要检查 JDK 安装是否存在。如果没有,请退出安装。如果不是因为我使用 TOutPutProgressWiazrdPage 向用户说明此过程,这似乎很简单。在“中止”或“退出”之前一切都很好。在遇到其中任何一个之后,安装就会变得混乱。请任何帮助,我们将不胜感激。我的示例代码如下:

//JDK Install
procedure InstallJDK();
var
  ErrorCode, x: Integer;
  Return,Path: String;
  Paths: TArrayOfString;
begin
    if (IsComponentSelectedLog('Prerequisites\JDK')) then
    begin
    GetJavaVersion();
    Path := GetEnv('path'); //(TNG-1463) 
        if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_LESS_THAN) and (Installed_Java_Version <> '') then
        begin
            if (Pos(Lowercase(JDK_ORACLE_DIR + '\jdk1.6.0_18'), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_SUN_DIR + '\jdk1.6.0_18'), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_ORACLE_DIR + '\jdk1.6.0_22'), Lowercase(Path)) <> 0)then
            begin
                SetFormText('Removing JDK Version: ' + Installed_Java_Version + '...', 'Preparing System...', JavaInstallationPage);
                //Remove Java Update 1.6.0_18
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{26A24AE4-039D-4CA4-87B4-2F83216018FF} /L ' + TNG_Install_Log_Dir + '\ju_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 76);
                //Remove JDK 1.6.0_18
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{32A3A4F4-B792-11D6-A78A-00B0D0160180} /L ' + TNG_Install_Log_Dir + '\jdk_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 80);
                //Remove Java Update 1.6.0_22
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{26A24AE4-039D-4CA4-87B4-2F83216022FF} /L ' + TNG_Install_Log_Dir + '\ju_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 76);
                //Remove JDK 1.6.0_22
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{32A3A4F4-B792-11D6-A78A-00B0D0160220} /L ' + TNG_Install_Log_Dir + '\jdk_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 80);
                //Remove JDK 1.6.0_18 Directories
                if DirExists(JDK_SUN_DIR + '\jdk1.6.0_18') then
        begin
          DelTree(JDK_SUN_DIR + '\jdk1.6.0_18', True, True, True);
        end;
                if DirExists(JDK_ORACLE_DIR + '\jdk1.6.0_18') then
        begin
          DelTree(JDK_ORACLE_DIR + '\jdk1.6.0_18', True, True, True);
        end;
                //Remove JDK 1.6.0_22 Directories
                if DirExists(JDK_ORACLE_DIR + '\jdk1.6.0_22') then
        begin
          DelTree(JDK_ORACLE_DIR + '\jdk1.6.0_22', True, True, True);
        end;
                //Clean Up Path
                if (Pos(Lowercase(JDK_ORACLE_DIR), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_SUN_DIR), Lowercase(Path)) <> 0) then
                begin
                    Paths := Split(Path,';',0);
                    Path := '';
                    for x := 0 to GetArrayLength(Paths)-1 do
                    begin
                    if (Pos(Lowercase(JDK_ORACLE_DIR), Lowercase(Paths[x])) <> 0) or (Pos(Lowercase(JDK_SUN_DIR), Lowercase(Paths[x])) <> 0) then
                    begin
                      Paths[x] := '';
                    end;
                end;
                for x := 0 to GetArrayLength(Paths)-1 do
                begin
                    if Paths[x] <> '' then
                    begin
                        if path = '' then
                        begin
                            Path := Paths[x];
                        end
                        else
                            Path := Path + ';' + Paths[x];
                        end;
                    end;
                end;
                SetxEnv('path', ExpandConstant(Path));
                UpdateProgressBar(PBarPostInstall1, 100);
            end;
            GetJavaVersion();
        end;    

        if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_LESS_THAN) then
        begin
            //Install JDK
            Log('In Progress......Executing jdk-6u23-windows-i586.exe');
            UpdateProgressBar(PBarJavaInstall, 10);
            if (CheckSupportExist('jdk-6u23-windows-i586.exe')) then
      begin
        Create_Dir(ExpandConstant('{sd}\apps'), JavaInstallationPage);
        Create_Dir(JDK_ORACLE_DIR, JavaInstallationPage);
        Create_Dir(ExpandConstant('{sd}\TNG2.0'), JavaInstallationPage);
        Create_Dir(ExpandConstant('{sd}\TNG2.0\install'), JavaInstallationPage);
        SetFormText('Installing JDK Version: ' + JDK_MIN_VERSION + '...', 'Preparing System...', JavaInstallationPage);
        ShellExecLog('open', 'jdk-6u23-windows-i586.exe',  '/s /v /qn" ADDLOCAL=ALL REBOOT=SUPPRESS INSTALLDIR=' + JDK_Dir + ' /L ' + TNG_Install_Log_Dir + '\jdk_' + JDK_MIN_VERSION + '_install.log"', ExpandConstant('{src}\Support\'), SW_HIDE, ewNoWait, ErrorCode);
        UpdateProgressBarUntilProgressHasEnded('jdk-6u23-windows-i586.exe', 100, 2, JavaInstallationPage, PBarJavaInstall);

        GetJavaVersion();

        if (not (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL)) then
        begin
          Log('Failed......' + JDK + ' ' + JDK_MIN_VERSION + ' Installation : Versions do not match.');
          LogError('Failed......' + JDK + ' ' + JDK_MIN_VERSION + ' Installation');
          ExitSetup := True;
        end
        else if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) then
        begin
          Log('Success......' + JDK + ' ' + Installed_Java_Version + ' Installed');
          if GetEnv('JAVA_HOME') <> JDK_Dir then
          begin
            ErrorCode := SetxEnv('JAVA_HOME', ExpandConstant(JDK_Dir));
          end;
          //(TNG-1463) Prepend the %Java_Home%\bin so that it is the first JDK in the system's path
          SetxEnv('path', ExpandConstant(JDK_Bin_DIR + ';' +  Path));
        end;
      end
      else
      begin
        MsgBox('Please re-run the install after the jdk-6u23-windows-i586.exe support install is placed in the support folder.', mbInformation, MB_OK);
              Log('User chose not to install the ' + JDK + ' ' + JDK_MIN_VERSION);
        ExitSetup := True;
      end;
        end
        else if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) then
        begin
            Log('Already Installed......' + JDK + ' ' + JDK_MIN_VERSION);      
        end
        else
        begin
            LogError('Failed......' + JDK + ' Installation');
      ExitSetup := True; 
        end;
  end;
end;
//Activate Setup Page
//
procedure JavaInstallationPage_Activate(Page: TWizardPage);
var
  ErrorCode: Integer;
begin
//Install JDK
    InstallJDK()
  if (ExitSetup = True)  then
  begin
        try
        finally
            JavaInstallationPage.Hide;
        end;
    **Abort**;
  end;
end;

procedure InitializeWizard();
begin
  // Installation Page
  JavaInstallationPage := CreateOutputProgressPage('JDK Installation', 'Setup is preparing the system.....');
    //JavaInstallationPage := CreateCustomPage(wpSQL_No_SQL_SelectSqlServer, 'POS Manufacturer Settings', 'Please select a supported manufacturer or select default');  
  lblJavaInstallDescription1 := TLabel.Create(JavaInstallationPage);
    with lblJavaInstallDescription1 do
    begin
    Top := 1;
    Caption := '';
    AutoSize := True;
    Parent := JavaInstallationPage.Surface;
  end;
    lblJavaInstallDescription2 := TLabel.Create(PreInstallationPage);
    with lblJavaInstallDescription2 do
    begin
    Top := lblJavaInstallDescription1.Top + lblJavaInstallDescription1.Height + 5;
    Caption := 'Installing Java Development Kit...';
    AutoSize := True;
    Parent := JavaInstallationPage.Surface;
  end;
    PBarJavaInstall := TNewProgressBar.Create(JavaInstallationPage);
    with PBarJavaInstall do
    begin
    Parent := JavaInstallationPage.Surface;
    Width := JavaInstallationPage.SurfaceWidth;
    Top := lblJavaInstallDescription2.Top + lblJavaInstallDescription2.Height + 3;
    Height := 19;
    Max := 105;
  end;





  JavaInstallationPage.OnActivate := @JavaInstallationPage_Activate;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
    ErrorCode: Integer;
    DisplayJavaInstallPage: boolean;
    FileName: string;
    FileLines: TArrayOfString;

begin     
    if CurPageID = wpTomCatPortSettings then
    begin
        DisplayJavaInstallPage := True;
    end;
    if DisplayJavaInstallPage then
    begin    
        GetJavaVersion();
        if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) <> VERSION_EQUAL) then
        begin
            JavaInstallationPage.Show;
            try
            finally
                JavaInstallationPage.Hide;
            end;

            if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) <> VERSION_EQUAL) then
            begin
                **Abort**;          
            end;
        end;
    end;            

    if (not LocalesPopulated) and (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) and (PageCount >= 4) and isComponentSelected('XPressPOS\MWB\Locale') then 
    begin
        // Configure MWB_Localization Settings Page  
        FileName := ExpandConstant('{tmp}\GetAllAvailableLocalesbyLocale.class');
        ExtractTemporaryFile(ExtractFileName(FileName));
        FileName := ExpandConstant('{tmp}\GetLocaleDisplayName.class');
        ExtractTemporaryFile(ExtractFileName(FileName));
        FileName := ExpandConstant('{tmp}\GetLocaleByDescription.class');
        ExtractTemporaryFile(ExtractFileName(FileName));    

        if SelectedLangauge <> 'es' then
        begin
      #if Debug == "True"
      ShellExecLog('open', 'cmd', ExpandConstant('/K  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en US > .\Localizations.txt"'), '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
          #else
            ShellExecLog('open', 'cmd', ExpandConstant('/C  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en US > .\Localizations.txt"'), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
            #endif
        end
        else
        begin
      #if Debug == "True"
      ShellExecLog('open', 'cmd', ExpandConstant('/K  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en MX > .\Localizations.txt"'), '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
          #else
            ShellExecLog('open', 'cmd', ExpandConstant('/C  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale es MX > .\Localizations.txt"'), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
            #endif
        end;

        lstLocalizations.Items.clear;
        chkDisplayUnsupported.Checked := False;
        if LoadStringsFromFile(ExpandConstant('{tmp}\Localizations.txt'), FileLines) then
        begin
            for I := 0 to GetArrayLength(FileLines)-1 do
            begin
                if ((FileLines[I] = 'English (United States)') or (FileLines[I] = 'Spanish (Mexico)')) then
                begin
                    lstLocalizations.Items.Add(FileLines[I]);
                end;
            end;
        end;
    LocalesPopulated := True;
    end;  
    Result := True;     
end;

function BackButtonClick(CurPageID: Integer): Boolean;
begin
  PageCount := PageCount - 1;
  Result := True;
end;

I have been having an issue with this for a while. Until this post, I have never actually asked for help online.

I have written an installation program using Inno Setup. It installs many things, one of them being the current release of the Java Development Kit. My issue is I need to check whether or not the JDK install exist. If it doesn't, exit the install. This seems easy enough if it were not for the fact that I am using a TOutPutProgressWiazrdPage to illustrate this process to the user. Everything is fine up until the "Abort" or "Exit". After hitting either of these, the install goes haywire. Please, any help would be appreciated. My sample code is below:

//JDK Install
procedure InstallJDK();
var
  ErrorCode, x: Integer;
  Return,Path: String;
  Paths: TArrayOfString;
begin
    if (IsComponentSelectedLog('Prerequisites\JDK')) then
    begin
    GetJavaVersion();
    Path := GetEnv('path'); //(TNG-1463) 
        if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_LESS_THAN) and (Installed_Java_Version <> '') then
        begin
            if (Pos(Lowercase(JDK_ORACLE_DIR + '\jdk1.6.0_18'), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_SUN_DIR + '\jdk1.6.0_18'), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_ORACLE_DIR + '\jdk1.6.0_22'), Lowercase(Path)) <> 0)then
            begin
                SetFormText('Removing JDK Version: ' + Installed_Java_Version + '...', 'Preparing System...', JavaInstallationPage);
                //Remove Java Update 1.6.0_18
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{26A24AE4-039D-4CA4-87B4-2F83216018FF} /L ' + TNG_Install_Log_Dir + '\ju_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 76);
                //Remove JDK 1.6.0_18
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{32A3A4F4-B792-11D6-A78A-00B0D0160180} /L ' + TNG_Install_Log_Dir + '\jdk_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 80);
                //Remove Java Update 1.6.0_22
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{26A24AE4-039D-4CA4-87B4-2F83216022FF} /L ' + TNG_Install_Log_Dir + '\ju_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 76);
                //Remove JDK 1.6.0_22
                ShellExecLog('open', ExpandConstant('cmd'),ExpandConstant('/C "start /w MsiExec /qn /X {{32A3A4F4-B792-11D6-A78A-00B0D0160220} /L ' + TNG_Install_Log_Dir + '\jdk_' + Installed_Java_Version + '_uninstall.log"'), ExpandConstant('{sys}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
                UpdateProgressBar(PBarJavaInstall, 80);
                //Remove JDK 1.6.0_18 Directories
                if DirExists(JDK_SUN_DIR + '\jdk1.6.0_18') then
        begin
          DelTree(JDK_SUN_DIR + '\jdk1.6.0_18', True, True, True);
        end;
                if DirExists(JDK_ORACLE_DIR + '\jdk1.6.0_18') then
        begin
          DelTree(JDK_ORACLE_DIR + '\jdk1.6.0_18', True, True, True);
        end;
                //Remove JDK 1.6.0_22 Directories
                if DirExists(JDK_ORACLE_DIR + '\jdk1.6.0_22') then
        begin
          DelTree(JDK_ORACLE_DIR + '\jdk1.6.0_22', True, True, True);
        end;
                //Clean Up Path
                if (Pos(Lowercase(JDK_ORACLE_DIR), Lowercase(Path)) <> 0) or (Pos(Lowercase(JDK_SUN_DIR), Lowercase(Path)) <> 0) then
                begin
                    Paths := Split(Path,';',0);
                    Path := '';
                    for x := 0 to GetArrayLength(Paths)-1 do
                    begin
                    if (Pos(Lowercase(JDK_ORACLE_DIR), Lowercase(Paths[x])) <> 0) or (Pos(Lowercase(JDK_SUN_DIR), Lowercase(Paths[x])) <> 0) then
                    begin
                      Paths[x] := '';
                    end;
                end;
                for x := 0 to GetArrayLength(Paths)-1 do
                begin
                    if Paths[x] <> '' then
                    begin
                        if path = '' then
                        begin
                            Path := Paths[x];
                        end
                        else
                            Path := Path + ';' + Paths[x];
                        end;
                    end;
                end;
                SetxEnv('path', ExpandConstant(Path));
                UpdateProgressBar(PBarPostInstall1, 100);
            end;
            GetJavaVersion();
        end;    

        if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_LESS_THAN) then
        begin
            //Install JDK
            Log('In Progress......Executing jdk-6u23-windows-i586.exe');
            UpdateProgressBar(PBarJavaInstall, 10);
            if (CheckSupportExist('jdk-6u23-windows-i586.exe')) then
      begin
        Create_Dir(ExpandConstant('{sd}\apps'), JavaInstallationPage);
        Create_Dir(JDK_ORACLE_DIR, JavaInstallationPage);
        Create_Dir(ExpandConstant('{sd}\TNG2.0'), JavaInstallationPage);
        Create_Dir(ExpandConstant('{sd}\TNG2.0\install'), JavaInstallationPage);
        SetFormText('Installing JDK Version: ' + JDK_MIN_VERSION + '...', 'Preparing System...', JavaInstallationPage);
        ShellExecLog('open', 'jdk-6u23-windows-i586.exe',  '/s /v /qn" ADDLOCAL=ALL REBOOT=SUPPRESS INSTALLDIR=' + JDK_Dir + ' /L ' + TNG_Install_Log_Dir + '\jdk_' + JDK_MIN_VERSION + '_install.log"', ExpandConstant('{src}\Support\'), SW_HIDE, ewNoWait, ErrorCode);
        UpdateProgressBarUntilProgressHasEnded('jdk-6u23-windows-i586.exe', 100, 2, JavaInstallationPage, PBarJavaInstall);

        GetJavaVersion();

        if (not (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL)) then
        begin
          Log('Failed......' + JDK + ' ' + JDK_MIN_VERSION + ' Installation : Versions do not match.');
          LogError('Failed......' + JDK + ' ' + JDK_MIN_VERSION + ' Installation');
          ExitSetup := True;
        end
        else if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) then
        begin
          Log('Success......' + JDK + ' ' + Installed_Java_Version + ' Installed');
          if GetEnv('JAVA_HOME') <> JDK_Dir then
          begin
            ErrorCode := SetxEnv('JAVA_HOME', ExpandConstant(JDK_Dir));
          end;
          //(TNG-1463) Prepend the %Java_Home%\bin so that it is the first JDK in the system's path
          SetxEnv('path', ExpandConstant(JDK_Bin_DIR + ';' +  Path));
        end;
      end
      else
      begin
        MsgBox('Please re-run the install after the jdk-6u23-windows-i586.exe support install is placed in the support folder.', mbInformation, MB_OK);
              Log('User chose not to install the ' + JDK + ' ' + JDK_MIN_VERSION);
        ExitSetup := True;
      end;
        end
        else if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) then
        begin
            Log('Already Installed......' + JDK + ' ' + JDK_MIN_VERSION);      
        end
        else
        begin
            LogError('Failed......' + JDK + ' Installation');
      ExitSetup := True; 
        end;
  end;
end;
//Activate Setup Page
//
procedure JavaInstallationPage_Activate(Page: TWizardPage);
var
  ErrorCode: Integer;
begin
//Install JDK
    InstallJDK()
  if (ExitSetup = True)  then
  begin
        try
        finally
            JavaInstallationPage.Hide;
        end;
    **Abort**;
  end;
end;

procedure InitializeWizard();
begin
  // Installation Page
  JavaInstallationPage := CreateOutputProgressPage('JDK Installation', 'Setup is preparing the system.....');
    //JavaInstallationPage := CreateCustomPage(wpSQL_No_SQL_SelectSqlServer, 'POS Manufacturer Settings', 'Please select a supported manufacturer or select default');  
  lblJavaInstallDescription1 := TLabel.Create(JavaInstallationPage);
    with lblJavaInstallDescription1 do
    begin
    Top := 1;
    Caption := '';
    AutoSize := True;
    Parent := JavaInstallationPage.Surface;
  end;
    lblJavaInstallDescription2 := TLabel.Create(PreInstallationPage);
    with lblJavaInstallDescription2 do
    begin
    Top := lblJavaInstallDescription1.Top + lblJavaInstallDescription1.Height + 5;
    Caption := 'Installing Java Development Kit...';
    AutoSize := True;
    Parent := JavaInstallationPage.Surface;
  end;
    PBarJavaInstall := TNewProgressBar.Create(JavaInstallationPage);
    with PBarJavaInstall do
    begin
    Parent := JavaInstallationPage.Surface;
    Width := JavaInstallationPage.SurfaceWidth;
    Top := lblJavaInstallDescription2.Top + lblJavaInstallDescription2.Height + 3;
    Height := 19;
    Max := 105;
  end;





  JavaInstallationPage.OnActivate := @JavaInstallationPage_Activate;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
    ErrorCode: Integer;
    DisplayJavaInstallPage: boolean;
    FileName: string;
    FileLines: TArrayOfString;

begin     
    if CurPageID = wpTomCatPortSettings then
    begin
        DisplayJavaInstallPage := True;
    end;
    if DisplayJavaInstallPage then
    begin    
        GetJavaVersion();
        if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) <> VERSION_EQUAL) then
        begin
            JavaInstallationPage.Show;
            try
            finally
                JavaInstallationPage.Hide;
            end;

            if (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) <> VERSION_EQUAL) then
            begin
                **Abort**;          
            end;
        end;
    end;            

    if (not LocalesPopulated) and (CompareVersion(Installed_Java_Version, JDK_MIN_VERSION) = VERSION_EQUAL) and (PageCount >= 4) and isComponentSelected('XPressPOS\MWB\Locale') then 
    begin
        // Configure MWB_Localization Settings Page  
        FileName := ExpandConstant('{tmp}\GetAllAvailableLocalesbyLocale.class');
        ExtractTemporaryFile(ExtractFileName(FileName));
        FileName := ExpandConstant('{tmp}\GetLocaleDisplayName.class');
        ExtractTemporaryFile(ExtractFileName(FileName));
        FileName := ExpandConstant('{tmp}\GetLocaleByDescription.class');
        ExtractTemporaryFile(ExtractFileName(FileName));    

        if SelectedLangauge <> 'es' then
        begin
      #if Debug == "True"
      ShellExecLog('open', 'cmd', ExpandConstant('/K  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en US > .\Localizations.txt"'), '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
          #else
            ShellExecLog('open', 'cmd', ExpandConstant('/C  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en US > .\Localizations.txt"'), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
            #endif
        end
        else
        begin
      #if Debug == "True"
      ShellExecLog('open', 'cmd', ExpandConstant('/K  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale en MX > .\Localizations.txt"'), '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
          #else
            ShellExecLog('open', 'cmd', ExpandConstant('/C  "{sd}&&cd {tmp}\&&java GetAllAvailableLocalesbyLocale es MX > .\Localizations.txt"'), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
            #endif
        end;

        lstLocalizations.Items.clear;
        chkDisplayUnsupported.Checked := False;
        if LoadStringsFromFile(ExpandConstant('{tmp}\Localizations.txt'), FileLines) then
        begin
            for I := 0 to GetArrayLength(FileLines)-1 do
            begin
                if ((FileLines[I] = 'English (United States)') or (FileLines[I] = 'Spanish (Mexico)')) then
                begin
                    lstLocalizations.Items.Add(FileLines[I]);
                end;
            end;
        end;
    LocalesPopulated := True;
    end;  
    Result := True;     
end;

function BackButtonClick(CurPageID: Integer): Boolean;
begin
  PageCount := PageCount - 1;
  Result := True;
end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏雨凉 2024-10-19 18:37:43

我通过在 InializeSetup 例程中放置任何可能需要中止的检查来修复此问题。从那里开始中止工作正常。当我尝试在其他地方中止时,脚本无法正确退出并生成不可预测的异常。特别是当从 try Finalize 内部调用 abort 时。

I fixed this by placing any checks that could require aborting in the InializeSetup Routine. The abort works fine from there. When I try and abort elsewhere the script fails to exit correctly and generates unpredictable exceptions. Especially when calling abort from inside a try finalize.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文