== ezFIT Optimizer (for Clarujust) Installation ==
=== Installing Clarujust Proxy Files ===
;//----------------------------------------------------------------------------
;// Inno-script: clarujust-proxy-setup.iss
;//----------------------------------------------------------------------------
;//----------------------------------------------------------------------------
;// Global Defines
;//----------------------------------------------------------------------------
#define DefaultAppPath "Audina\ezFITOptimizer\"
...
;//----------------------------------------------------------------------------
;// Setup section
;//----------------------------------------------------------------------------
[Setup]
DefaultDirName={param:AppPath|{pf}\{#DefaultAppPath}}
...
[Files]
...
;//---------------------------------------------------
;// Clarujust files
;//---------------------------------------------------
Source: ..\ClarujustProxy\MockClarujustApp.dll; DestDir: {app}\Clarujust; Flags: ignoreversion
Source: ..\ClarujustProxy\ClarujustProxyServer.dll; DestDir: {app}\Clarujust; Flags: ignoreversion
;Source: ..\ClarujustProxy\ClarujustProxyServer.tlb; DestDir: {app}\Clarujust; Flags: ignoreversion
Source: ..\ClarujustProxy\Interop.EzFITOptimizerSvr.dll; DestDir: {app}\Clarujust; Flags: ignoreversion
...
[Run]
; RegAsm path: {win}\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe
Filename: {dotnet20}\RegAsm.exe; Parameters: ClarujustProxyServer.dll /codebase /silent; WorkingDir: {app}\Clarujust\; Flags: skipifdoesntexist runhidden
...
[UninstallRun]
; RegAsm path: {win}\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe
Filename: {dotnet20}\RegAsm.exe; Parameters: ClarujustProxyServer.dll /unregister; WorkingDir: {app}\Clarujust\; Flags: skipifdoesntexist runhidden
...
=== ezFIT Installer Executing Clarujust Installer ===
ezFIT installer would call the Clarujust installer and provide the ezFIT installation path, so that Clarujust can install itself relative to that path. This information is better provided during installation as a command-line parameter rather than reading the Windows Registry, since some of those entries might not have been created or updated yet.
===== Script Sample =====
Calling Clarujust Inno-setup script with a parameter ''AppPath'' to let it know the ezFIT path:
;//----------------------------------------------------------------------------
;// Inno-script: ezfit-clarujust-setup.iss
;//----------------------------------------------------------------------------
...
[Files]
;//---------------------------------------------------
;// Application files
;//---------------------------------------------------
Source: {src}\clarujust-setup.exe; DestDir: {src}; Flags: ignoreversion external skipifsourcedoesntexist dontcopy
...
[Run]
Filename: {src}\clarujust-setup.exe; Parameters: /AppPath={app}; Description: {cm:LaunchProgram,clarujust-setup.exe}; Flags: skipifdoesntexist
...
Clarujust Inno-setup script using the ''AppPath'' command-line parameter to set target installation path for Clarujust:
;//----------------------------------------------------------------------------
;// Inno-script: clarujust-setup.iss
;//----------------------------------------------------------------------------
;//----------------------------------------------------------------------------
;// Global Defines
;//----------------------------------------------------------------------------
#define DefaultAppPath "Audina\ezFITOptimizer\"
...
;//----------------------------------------------------------------------------
;// Setup section
;//----------------------------------------------------------------------------
[Setup]
;DefaultDirName={code:GetAppPath}\Clarujust
DefaultDirName={param:AppPath|{pf}\{#DefaultAppPath}\Clarujust}
...
[Files]
;//---------------------------------------------------
;// Clarujust files
;//---------------------------------------------------
Source: ..\ClarujustProxy\MockClarujustApp.dll; DestDir: {app}; Flags: ignoreversion
Source: ..\ClarujustProxy\ClarujustProxyServer.dll; DestDir: {app}; Flags: ignoreversion
Source: ..\ClarujustProxy\ClarujustProxyServer.tlb; DestDir: {app}; Flags: ignoreversion
Source: ..\ClarujustProxy\Interop.EzFITOptimizerSvr.dll; DestDir: {app}; Flags: ignoreversion
...
[Run]
Filename: {dotnet20}\RegAsm.exe; Parameters: ClarujustProxyServer.dll /codebase /silent; WorkingDir: {app}; Flags: skipifdoesntexist runhidden
...
[UninstallRun]
Filename: {dotnet20}\RegAsm.exe; Parameters: ClarujustProxyServer.dll /unregister; WorkingDir: {app}; Flags: skipifdoesntexist runhidden
[Code]
//----------------------------------------------------------------------------
// function prototypes
//----------------------------------------------------------------------------
function GetAppPath(): string; forward;
...
//----------------------------------------------------------------------------
// description: get the applicaton path sent by command-line param /AppPath
// parameters : void
// return : pth (string)
//----------------------------------------------------------------------------
function GetAppPath(): string;
var
pth: string;
begin
// ezFIT installer will pass ezFIT's target path to the Clarujust installer (as a command line parameter).
// We get this parameter and extract the path to determine where Clarujust will be installed.
// InnoSetup receives it as Param 2.
// For example: Param 1 = /SL5="$2074A,72847574,53248,D:\...\innosetup\output\ezfit-setup.exe"
// Param 2 = /ezfitpath="C:\Program Files\Audina\ezFIT4"
pth := ExpandConstant('{param:AppPath|{pf}\{#DefaultAppPath}}');
Log('GetAppPath(): pth=['+pth+']');
result := pth;
end;
=== Clarujust Installer Executing ezFIT Installer ===
The ezFIT installer already creates a Windows registry entry that can bed use for querying its version and installation path:
For ezFIT Stand-alone:
HKEY_LOCAL_MACHINE\Software\Audina Hearing Instruments\ezFIT\4.0\Setup\Product Path
HKEY_LOCAL_MACHINE\Software\Audina Hearing Instruments\ezFIT\4.0\Setup\Version
Example:
* Product Path: ''C:\Program Files\Audina\ezFIT4''
* Version: ''4.212009102701''
For ezFIT for Noah:
HKEY_LOCAL_MACHINE\Software\Audina Hearing Instruments\ezFIT\4.0\Setup\Noah Product Path
HKEY_LOCAL_MACHINE\Software\Audina Hearing Instruments\ezFIT\4.0\Setup\ezFIT NOAH Version
Example:
* Noah Product Path: ''C:\PROGRA~1\HIMSA\Modules\Fitting\044''
* ezFIT NOAH Version: ''4.212009102701''
The Clarujust installer should probably check that ezFIT has been installed (by checking the path and version in the Windows registry), and then it can proceed with the installation.
===== Sample Script =====
This sample script shows how to check if ezFIT (Stand-alone) is installed on the system, and if it is not, then we install it. It also describes how to get the installation path from the Windows registry. Please note: a similar logic needs to be implemented to check for a ezFIT for Noah version installation, since either can be present in the system.
;//----------------------------------------------------------------------------
;// Inno-script: clarujust-ezfit-setup.iss
;//----------------------------------------------------------------------------
...
[Files]
;//---------------------------------------------------
;// Application files
;//---------------------------------------------------
Source: {src}\ezfit-setup.exe; DestDir: {src}; Flags: ignoreversion external skipifsourcedoesntexist dontcopy; Languages:
...
[Run]
Filename: {src}\ezfit-setup.exe; Description: {cm:LaunchProgram,ezfit.exe}; Flags: skipifdoesntexist; Check: NoValidEzFitExists('4.212009121601')
...
[Code]
//----------------------------------------------------------------------------
// Function prototypes
//----------------------------------------------------------------------------
function GetEzfitPath(): string; forward;
function GetEzfitVersion(): string; forward;
function NoValidEzFitExists(ValidVersion: string): Boolean; forward;
...
//----------------------------------------------------------------------------
// description: get the correct ezFIT path (installation dir).
// parameters : void
// return : pth (string)
//----------------------------------------------------------------------------
function GetEzfitPath(): string;
var
pth: string;
begin
// Registry: HKEY_LOCAL_MACHINE\Software\Audina Hearing Instruments\ezFIT\4.0\Setup\Product Path
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Audina Hearing Instruments\ezFIT\4.0\Setup\', 'Product Path', pth);
if trim(pth) <> '' then begin
if DirExists(pth) then begin
pth := trim(pth);
if ForceDirectories(pth) then begin
Log('GetEzfitPath(): created dir pth=['+pth+']');
end else begin
Log('GetEzfitPath(): not created dir pth=['+pth+']');
end;
end;
end else begin
Log('GetEzfitPath(): ezFIT not installed in this system.');
end;
result := pth;
end;
//----------------------------------------------------------------------------
// description: get the current ezFIT version.
// parameters : void
// return : ver (string)
//----------------------------------------------------------------------------
function GetEzfitVersion(): string;
var
ver: string;
begin
// Registry: HKEY_LOCAL_MACHINE\Software\Audina Hearing Instruments\ezFIT\4.0\Setup\Version
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Audina Hearing Instruments\ezFIT\4.0\Setup\', 'Version', ver);
if trim(ver) <> '' then begin
Log('GetEzfitVersion(): ezFIT ver=['+ver+']');
end else begin
Log('GetEzfitVersion(): ezFIT not installed');
end;
result := ver;
end;
//----------------------------------------------------------------------------
// description: Verify there is no prior valid ezFIT installation in system.
// If there is a valid installation, we do not reinstall ezFIT, that is why
// we check for no valid install in order to execute ezFIT installer.
// parameters : ValidVersion: string. Format: V.vvBBBBBBBBBB
// V = Major version
// v = Minor version
// B = Build number
// Example: 4.212009121601 -> version 4.21, build 2009-12-16 (number 01)
// return : T if no valid installation, F if there is a valid installation
//----------------------------------------------------------------------------
function NoValidEzFitExists(ValidVersion: string): Boolean;
var
curBuild, validBuild: integer;
curVer, validVer: integer;
begin
result := False; // A valid ezFIT install exists already
if (GetEzfitPath() <> '') then begin
curVer := StrToInt(copy(GetEzfitVersion(), 1, 4));
validVer := StrToInt(copy(ValidVersion, 1, 4));
curBuild := StrToInt(copy(GetEzfitVersion(), 5, 10));
validBuild := StrToInt(copy(ValidVersion, 5, 10));
if ((curVer < validVer) or (curBuild < validBuild)) then begin
result := True; // No valid ezFIT install exists
end;
end;
end;