To prevent the message "An existing firebird xxx server is running...." in InitializeSetup
you may check whether Firebird server is running and its version.
If it is running and the installed version is not correct you may do something
(stop the instalation, or continue instalation without installing Firebird or something else).
How to do it
First You should find and download the files :
FirebirdInstallSupportFunctions.inc
CheckIbaseFirebirdInstaled.inc
and include them in code section:
[Code]
.....
#include "FirebirdInstallSupportFunctions.inc"
#include "CheckIbaseFirebirdInstaled.inc"
.....
In 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;
Used constants and variables
[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;
Used functions
//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;
Update
In InitializeWizard may use InstallSqlServer
variable to show or hide "Install Firebird page" like this :
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;
Firebird
installed and its version. If the installed version is not correct I warn the user. If the version is correct, I continue the installation without installingFirebird
. I'll show the code a little later. – Val Marinov