使用inno设置安装firebird

时间:2015-07-12 13:28:53

标签: inno-setup firebird

我尝试使用Inno Setup安装firebird以及我的应用程序但是我有两个问题我无法解决:

  1. 如果计算机中已安装Firebird,则在安装过程中会弹出一条消息:"An existing firebird xxx server is running. You must close the application or stop the service before continuing"。如果您已经安装了Firebird,我该如何忽略它?我尝试了几个标志,留下了更多信息。

  2. 如何让安装程序等待Firebird的安装完成,然后才运行应用程序?因为我正在做的方式,它开始在后台安装Firebird,只是不希望完成,如果用户必须在安装结束时点击打开程序,将因为系统而给出错误仍无法打开数据库,因为firebird仍在后台安装。

  3. 如何解决这两个问题?

2 个答案:

答案 0 :(得分:2)

在InitializeSetup中阻止消息“现有的firebird xxx服务器正在运行....” 您可以检查Firebird服务器是否正在运行及其版本。 如果它正在运行且安装的版本不正确,您可以执行某些操作 (停止安装,或继续安装而不安装Firebird或其他东西)。

怎么做

首先您应该找到并下载文件:

FirebirdInstallSupportFunctions.inc

CheckIbaseFirebirdInstaled.inc

并将其包含在代码部分中:

[Code]
.....
#include "FirebirdInstallSupportFunctions.inc"
#include "CheckIbaseFirebirdInstaled.inc"
.....

InitializeSetup

function InitializeSetup():boolean;
var
  MsgResult : Integer;
  MsgText: String;
begin
   InstallSqlServer := true;

   //check for installed Firebird server version
   SQLServerRunning := IsSQlServerRunning;

   SQLServerInstalledVersion := GetSQLInstalledVersion;   
   case SQLServerInstalledVersion of
      0 : begin 
            if SQLServerRunning <> RUN_NONE then
              begin
                // there is an old version running ( InstalledVersion return 0 but server is running anyway)
                MsgText := '....message.........';
                MsgResult := MsgBox(MsgText,mbConfirmation,MB_OK);  //Show warning message
                result := false;  //Abort Setup
                exit;
              end
            else
              result := true;                 
      end;
      FB_INSTALLED_IS_NOT_VALID : begin
        MsgText := 'There is installed  ' + SummarizeInstalledProducts + #13 + 'This program required at least'+ '{#SQLServerVersion}'+ #13 + 'Do you want to continue?'  ;
        result := false;
        MsgResult := MsgBox(MsgText,mbConfirmation,MB_YESNO);
        if MsgResult = IDYES then 
          begin
            result := true;  //Continue setup
          end
        else 
          begin
            result := false;  //Abort Setup
          end;
      end
      FB_INSTALLED_IS_VALID : begin
        InstallSqlServer := false;  // The correct  Firebird server is installed 
        result := true;             //Continue Setup
      end
  end;
end;

使用过的常量和变量

[Code]
const 
  FB_IS_NOT_INSTALED = 0;
  FB_INSTALLED_IS_NOT_VALID = -1;
  FB_INSTALLED_IS_VALID = 1;
  FB_UNKNOWN = 2;

  RUN_NONE = 0;
  RUN_FB1_IB = 1;
  RUN_FB = 2;
  RUN_FB_21_25 = 3;
  .....

var 
  InstallSqlServer : boolean;
  SQLServerInstalledVersion : integer;

使用过的功能

//this function checks if Firebird is running
function IsSQlServerRunning : integer;
begin
  if FirebirdDefaultServerRunning then
    begin
      if RunningServerVerString = 'Firebird v1.0 / InterBase' then
        begin
          result := RUN_FB1_IB; 
        end;
      if RunningServerVerString = 'Firebird' then
        begin
          result := RUN_FB;
        end;
      if RunningServerVerString = 'Firebird v2.1 or v2.5' then
        begin
           result := RUN_FB_21_25;
        end;
     end
   else
     result := RUN_NONE;
end;

//Is this is a correct version
function AnalysisAssessment: integer;
var
  MsgText: String;
  MsgResult: Integer;
  VerString: String;
begin
  if ProductsInstalledCount = 0 then
    begin
      FirebirdInstalledRootDir := ExpandConstant('{pf}') + '\' + ExpandConstant('{#FirebirdDir}');
      result := FB_IS_NOT_INSTALED;
      exit;
    end
   else
     if ProductsInstalledCount = 1 then
       begin
         if (ProductsInstalled < FB25) then // See CheckIbaseFirebirdInstaled.inc ->ProductsInstalled const
            result := FB_INSTALLED_IS_NOT_VALID
     else
       result := FB_INSTALLED_IS_VALID;
   end
 else
    result := FB_UNKNOWN;
end;

//this function gets installed version
function GetSQLInstalledVersion : integer;
begin
  InitExistingInstallRecords;
  AnalyzeEnvironment;
  result := AnalysisAssessment;
end;


function SummarizeInstalledProducts: String;
var
  InstallSummaryArray: TArrayofString;
  product: Integer;
  i: Integer;
begin

//do nothing gracefully if we are called by accident.
  if ProductsInstalledCount = 0 then
begin
  FirebirdInstalledRootDir := ExpandConstant('{pf}') + '\' + ExpandConstant('{#FirebirdDir}');
  exit;
end;
  i := 0;

  SetArrayLength(InstallSummaryArray,ProductsInstalledCount);

  for product := 0 to MaxProdInstalled -1 do
begin
   if (ProductsInstalledArray[product].InstallType <> NotInstalled) then
   //   result := result + intToStr(ProductsInstalledArray[product].ProductID);
   case ProductsInstalledArray[product].ProductID of
      IB4Install : result := result + ' Interbase 4' + #13;
      IB5Install : result := result + ' Interbase 5' + #13;
      IB6Install : result := result + ' Interbase 6' + #13;
      IB65Install : result := result + ' Interbase 6.5' + #13;
      IB70Install :result := result + ' Interbase 7' + #13;
      FB1Install  :result := result + ' Firebird 1' + #13;
      FB15RCInstall : result := result + ' Firebird 1.5RC' + #13;
      FB15Install  : result := result + ' Firebird 1.5' + #13;
      FB20Install  : begin
                      result := result + ' Firebird 2.0' + #13
                      FirebirdInstalledRootDir :=  ProductsInstalledArray[product].path;
                    end;
      IB80Install  : result := result + ' Interbase 8' + #13;
      IB81Install  : result := result + ' Interbase 8' + #13;
      FB21Install  : result := result + ' Firebird 2.1' + #13;
      FB21_x64_Install  : result := result + ' Firebird 2.1_x64' + #13;
      FB25Install   : result := result + ' Firebird 2.5' + #13;
      FB25_x64_Install  : result := result + ' Firebird 2.5_x64' + #13;
      FB30Install    : result := result + ' Firebird 3' + #13;
      FB30_x64_Install  : result := result + ' Firebird 3_x64' + #13;
   end;//case
end;
end;

更新

InitializeWizard 中,可以使用InstallSqlServer变量来显示或隐藏“安装Firebird页面”,如下所示:

procedure InitializeWizard;
begin
  CreateActionSelectPage;
end;

procedure CreateActionSelectPage;
begin
  ActionPage := CreateInputOptionPage(wpWelcome,
                                  CustomMessage('ActionPageName'), 
                                  CustomMessage('ActionPageDescription'),
                                  CustomMessage('ActionPageMsg'),
                                  False, False);

  ActionPage.Add(CustomMessage('InstallSQLSvr'));   
  ActionPage.Add(CustomMessage('InstallDatabase'));   
  ActionPage.Add(CustomMessage('InstallClientProgram'));  


  ActionPage.Values[0] := InstallSQLServer;
  ActionPage.Values[1] := True;
  ActionPage.Values[2] := True; 
end;

答案 1 :(得分:0)

等待install_super.bat终止

[Run]
Filename: {app}\FB\bin\install_super.bat; WorkingDir: {app}\FB\BIN; Languages: ru; Components: fbserver database; Flags: waituntilterminated