Inno 64
Inno 64
Inno 64
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Controle da Livraria"
#define MyAppVersion "1.0"
#define MyAppPublisher "Srgio Henique"
#define MyAppURL "https://sites.google.com/site/controledelivraria/"
#define MyAppExeName "Controle da Livraria.exe"
#define AppFilesFolder = 'C:\Users\Srgio\Documents\Visual Studio 2013\Projects\Co
ntrole da Livraria\Instalador\Files\AppFiles'
#define NetFrameworkFolder = 'C:\Users\Srgio\Documents\Visual Studio 2013\Project
s\Controle da Livraria\Instalador\Files\NET'
#define SQLLocalDBFolder = 'C:\Users\Srgio\Documents\Visual Studio 2013\Projects\
Controle da Livraria\Instalador\Files\SQL Local DB'
#define AssistantsFolder = 'C:\Users\Srgio\Documents\Visual Studio 2013\Projects\
Controle da Livraria\Instalador\Files\Assistants'
#define FontsFolder = 'C:\Users\Srgio\Documents\Visual Studio 2013\Projects\Contr
ole da Livraria\Instalador\Files\Fonts'
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{ABFDCBC9-AF49-4E0D-B318-55186EDE9F16}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\Srgio\Documents\Visual Studio 2013\Projects\Controle da Livrar
ia\Instalador
OutputBaseFilename=Setup - x64
SetupIconFile=C:\Users\Srgio\Documents\Visual Studio 2013\Projects\Controle da Li
vraria\Instalador\Setup icon.ico
Compression=lzma
SolidCompression=yes
UninstallFilesDir={app}\Uninstall
[Languages]
;Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortugue
se.isl"
[Dirs]
Name: "{app}\Data"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip
tion: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "{#AppFilesFolder}\Controle da Livraria.application"; DestDir: "{app}\Da
ta"; Flags: ignoreversion
Source: "{#AppFilesFolder}\Controle da Livraria.exe"; DestDir: "{app}\Data"; Fla
gs: ignoreversion
Source: "{#AppFilesFolder}\Controle da Livraria.exe.config"; DestDir: "{app}\Dat
a"; Flags: ignoreversion
Source: "{#AppFilesFolder}\Controle da Livraria.exe.manifest"; DestDir: "{app}\D
ata"; Flags: ignoreversion
Source: "{#AppFilesFolder}\DatabaseSupport.dll"; DestDir: "{app}\Data"; Flags: i
gnoreversion
Source: "{#AppFilesFolder}\Interaction.dll"; DestDir: "{app}\Data"; Flags: ignor
eversion
Source: "{#AppFilesFolder}\System.Windows.Interactivity.dll"; DestDir: "{app}\Da
ta"; Flags: ignoreversion
Source: "{#AppFilesFolder}\Xceed.Wpf.AvalonDock.dll"; DestDir: "{app}\Data"; Fla
gs: ignoreversion
Source: "{#AppFilesFolder}\Xceed.Wpf.AvalonDock.Themes.Aero.dll"; DestDir: "{app
}\Data"; Flags: ignoreversion
Source: "{#AppFilesFolder}\Xceed.Wpf.AvalonDock.Themes.Metro.dll"; DestDir: "{ap
p}\Data"; Flags: ignoreversion
Source: "{#AppFilesFolder}\Xceed.Wpf.AvalonDock.Themes.VS2010.dll"; DestDir: "{a
pp}\Data"; Flags: ignoreversion
Source: "{#AppFilesFolder}\Xceed.Wpf.DataGrid.dll"; DestDir: "{app}\Data"; Flags
: ignoreversion
Source: "{#AppFilesFolder}\Xceed.Wpf.Toolkit.dll"; DestDir: "{app}\Data"; Flags:
ignoreversion
Source: "{#NetFrameworkFolder}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe"; DestDir:
"{tmp}"; AfterInstall:InstallFramework; Flags: deleteafterinstall; Check:not D
etectNetFramework
Source: "{#SQLLocalDBFolder}\SqlLocaLDB x64.msi"; DestDir: "{tmp}"; Flags: delet
eafterinstall; Check:not DetectSQLLocalDB;
Source: "{#AssistantsFolder}\RemoveDB.exe"; DestDir: "{app}\Uninstall"; Flags: i
gnoreversion
Source: "{#FontsFolder}\Segoe UI Sym.ttf"; DestDir: "{fonts}"; FontInstall: "Seg
oe UI Symbol Regular"; Flags: fontisnttruetype uninsneveruninstall
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\Data\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Data\{#MyAppExeName}"; Ta
sks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Fil
ename: "{app}\Data\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\Data\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#String
Change(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent;StatusMs
g: "Instalando Controle da Livraria..."
Filename: {tmp}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe; Parameters: "/q /noresta
rt"; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Instalando .NET Fr
amework 4.5.1 - A instalao poder levar alguns minutos, no cancele ou desligue o comp
utador";
Filename: "msiexec.exe"; Parameters: "/i""{tmp}\SqlLocaLDB x64.msi""/qn IACCEPTS
QLLOCALDBLICENSETERMS=YES"; WorkingDir: {tmp}; Flags: skipifdoesntexist; Status
Msg: "Instalando SQL DB Local";
[UninstallRun]
Filename:"{app}\Uninstall\RemoveDB.exe";
[Code]
procedure InstallFramework;
var
StatusText: string;
begin
StatusText := 'Instalando .NET Framework 4.5.1 - A instalao poder levar alguns mi
nutos, no cancele ou desligue o computador';
WizardForm.StatusLabel.Caption := 'Instalando .NET Framework 4.5.1...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
// here put the .NET setup execution code
finally
// WizardForm.StatusLabel.Caption := StatusText;
//WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
//BAR PROGRESS//////////////////////////////////////////////////////////////////
//////////////////
function GetTickCount: DWORD;
external 'GetTickCount@kernel32.dll stdcall';
var
StartTick: DWORD;
PercentLabel: TNewStaticText;
ElapsedLabel: TNewStaticText;
RemainingLabel: TNewStaticText;
function TicksToStr(Value: DWORD): string;
var
I: DWORD;
Hours, Minutes, Seconds: Integer;
begin
I := Value div 1000;
Seconds := I mod 60;
I := I div 60;
Minutes := I mod 60;
I := I div 60;
Hours := I mod 24;
Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
end;
//BAR PROGRESS//////////////////////////////////////////////////////////////////
//////////////////
procedure InitializeWizard;
begin
PercentLabel := TNewStaticText.Create(WizardForm);
PercentLabel.Parent := WizardForm.ProgressGauge.Parent;
PercentLabel.Left := 0;
PercentLabel.Top := WizardForm.ProgressGauge.Top +
WizardForm.ProgressGauge.Height + 12;
ElapsedLabel := TNewStaticText.Create(WizardForm);
ElapsedLabel.Parent := WizardForm.ProgressGauge.Parent;
ElapsedLabel.Left := 0;
ElapsedLabel.Top := PercentLabel.Top + PercentLabel.Height + 4;
RemainingLabel := TNewStaticText.Create(WizardForm);
RemainingLabel.Parent := WizardForm.ProgressGauge.Parent;
RemainingLabel.Left := 0;
RemainingLabel.Top := ElapsedLabel.Top + ElapsedLabel.Height + 4;
end;
//BAR PROGRESS//////////////////////////////////////////////////////////////////
//////////////////
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpInstalling then
StartTick := GetTickCount;
end;
//BAR PROGRESS//////////////////////////////////////////////////////////////////
//////////////////
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
if CurPageID = wpInstalling then
begin
Cancel := False;
if ExitSetupMsgBox then
begin
Cancel := True;
Confirm := False;
PercentLabel.Visible := False;
ElapsedLabel.Visible := False;
RemainingLabel.Visible := False;
end;
end;
end;
//BAR PROGRESS//////////////////////////////////////////////////////////////////
//////////////////
procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
var
CurTick: DWORD;
begin
CurTick := GetTickCount;
PercentLabel.Caption :=
Format('Completado: %.2f %%', [(CurProgress * 100.0) / MaxProgress]);
ElapsedLabel.Caption :=
Format('Tempo decorrido: %s', [TicksToStr(CurTick - StartTick)]);
if CurProgress > 0 then
begin
RemainingLabel.Caption :=
Format('Tempo restante: %s', [TicksToStr(
((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
end;
end;
//Detect NET Framework//////////////////////////////////////////////////////////
///////////////////////////
function IsNetFrameworkDetected(version: string; service: cardinal): boolean;
// Indicates whether the specified version and service pack of the .NET Framewor
k is installed.
//
// version -- Specify one of these strings for the required .NET Framework versi
on:
// 'v1.1.4322' .NET Framework 1.1
// 'v2.0.50727' .NET Framework 2.0
// 'v3.0' .NET Framework 3.0
// 'v3.5' .NET Framework 3.5
// 'v4\Client' .NET Framework 4.0 Client Profile
// 'v4\Full' .NET Framework 4.0 Full Installation
// 'v4.5' .NET Framework 4.5
//
// service -- Specify any non-negative integer for the required service pack lev
el:
// 0 No service packs required
// 1, 2, etc. Service pack 1, 2, etc. required
var
key: string;
install, release, serviceCount: cardinal;
check45, success: boolean;
var reqNetVer : string;
begin
// .NET 4.5 installs as update to .NET 4.0 Full
if version = 'v4.5' then begin
version := 'v4\Full';
check45 := true;
end else
check45 := false;
// installation key group for all .NET versions
key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
// .NET 3.0 uses value InstallSuccess in subkey Setup
if Pos('v3.0', version) = 1 then begin
success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', in
stall);
end else begin
success := RegQueryDWordValue(HKLM, key, 'Install', install);
end;
// .NET 4.0/4.5 uses value Servicing instead of SP
if Pos('v4', version) = 1 then begin
success := success and RegQueryDWordValue(HKLM, key, 'Servicing', servic
eCount);
end else begin
success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount)
;
end;
// .NET 4.5 uses additional value Release
if check45 then begin
success := success and RegQueryDWordValue(HKLM, key, 'Release', release)
;
success := success and (release >= 378758) or (release >= 378675) ;
end;
result := success and (install = 1) and (serviceCount >= service);
end;
function DetectNetFramework(): Boolean;
begin
result := IsNetFrameworkDetected('v4.5', 0);
end;
function DetectSQLLocalDB(): Boolean;
var
sVersion: String;
currentVersion1: String;
currentVersion2: String;
currentVersion3: String;
res: Boolean;
begin
currentVersion1:='11.0.2100.60';
currentVersion2:='11.1.3128.0';
currentVersion3:='11.1.3128.0';
sVersion := '';
res:=false;
if IsWin64 then
begin
if RegQueryStringValue(HKLM64, 'SOFTWARE\Microsoft\Microsoft SQL Server\MS
SQL11E.LOCALDB\MSSQLServer\CurrentVersion', 'Version', sVersion ) then
begin
if not (sVersion = '') then
begin
res:=true;
end
end
end
else
begin
if RegQueryStringValue(HKLM32, 'SOFTWARE\Microsoft\Microsoft SQL Server\MS
SQL11E.LOCALDB\MSSQLServer\CurrentVersion', 'Version', sVersion ) then
begin
if not (sVersion = '') then
begin
res:=true;
end
end
end;
Result := res;
end;