; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define ApplicationVersion GetFileVersion('..\Release\Win32\WinBib.exe')
#define Year GetDateTimeString('yyyy','','')

[Setup]
PrivilegesRequired=admin
AppName=WinBib
AppVerName=WinBib {#ApplicationVersion}
AppVersion={#ApplicationVersion}
AppPublisher=J. Rathlev, 24222 Schwentinental, Germany
AppPublisherURL=http://www.my-domain.de/
AppSupportURL=http://www.my-domain.de/
AppUpdatesURL=http://www.my-domain.de/
AppCopyright=Copyright © 2012-[#Year] Dr. J. Rathlev
VersionInfoVersion={#ApplicationVersion}
DefaultDirName={pf}\WinBib
AppendDefaultDirName=yes
DefaultGroupName=WinBib
InfoAfterFile=..\Dokumentation\changelog.txt
OutputDir=.
OutputBaseFilename=winbib-setup
SetupIconFile=winbib.ico
UninstallDisplayIcon=winbib.ico
WizardImageFile=..\..\Common\WizImage-JR.bmp
WizardSmallImageFile=..\..\Common\WizSmallImage-JR.bmp
Compression=lzma
SolidCompression=yes
ChangesAssociations=yes
ShowLanguageDialog=auto
DisableDirPage=auto
DisableProgramGroupPage=auto

[Languages]
Name: "en"; MessagesFile: compiler:Default.isl; LicenseFile:"..\..\Common\license-en.txt"; InfoBeforeFile:"..\Dokumentation\notes-en.txt"
Name: "de"; MessagesFile: compiler:Languages\German.isl; LicenseFile:"..\..\Common\license-de.txt"; InfoBeforeFile:"..\Dokumentation\notes-de.txt"

[CustomMessages]
en.FileAssoc=File associations:
de.FileAssoc=Dateizuordnungen:
en.DescContext=Open "bib" files with WinBib
de.DescContext="bib"-Dateien mit WinBib öffnen
en.Update=WinBib is already installed on your system!
de.Update=WinBib ist bereits auf Ihrem System installiert!
en.StartUpdate=Clicking the "Next" button will start the update.
de.StartUpdate=Ein Klick auf die "Weiter"-Taste startet das Update.

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
; Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "fileassoc"; Description: "{cm:DescContext}"; GroupDescription: "{cm:FileAssoc}"

[Files]
Source: "..\Release\Win32\WinBib.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace
Source: "..\Release\Win32\PdfToText.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace
Source: "..\Release\Win32\locale\*.mo"; DestDir: "{app}\locale"; Flags: recursesubdirs ignoreversion restartreplace
Source: "..\Release\Win32\language.cfg"; DestDir: "{app}"; Flags: recursesubdirs ignoreversion restartreplace
Source: "..\Release\Win32\*.csv"; DestDir: "{userdocs}\WinBib"; Flags: recursesubdirs ignoreversion restartreplace
Source: "..\Release\Win32\templates\*.*"; DestDir: "{userdocs}\WinBib\Templates"; Flags: recursesubdirs ignoreversion restartreplace
Source: "..\..\Common\license-*.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Dokumentation\notes-*.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Dokumentation\changelog.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Dokumentation\WinBib.pdf"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\WinBib"; Filename: "{app}\WinBib.exe"
Name: "{group}\{cm:UninstallProgram,WinBib}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\WinBib"; Filename: "{app}\WinBib.exe"; Tasks: desktopicon

[Run]
Filename: "{app}\WinBib.exe"; Description: "{cm:LaunchProgram,WinBib}"; Flags: nowait postinstall runasoriginaluser

[Registry]
Root: HKCR; Subkey: ".bib"; ValueType: string; ValueName: ""; ValueData: "BibTexFile"; Tasks: fileassoc; Flags: uninsdeletevalue
Root: HKCR; Subkey: "BibTexFile"; ValueType: string; ValueName: ""; ValueData: "WinBib"; Tasks: fileassoc; Flags: uninsdeletekey
Root: HKCR; Subkey: "BibTexFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\WinBib.exe,0"; Tasks: fileassoc
Root: HKCR; Subkey: "BibTexFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\WinBib.exe"" ""%1"""; Tasks: fileassoc

[Code]
function IsUpdate :boolean;
begin
  if IsWin64 then Result:=RegKeyExists(HKLM,'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\WinBib_is1')
  else Result:=RegKeyExists(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinBib_is1');
end;
  
function ReadVersionNumber (const FName : string) : string;
var
  sv : string;
begin
  if GetVersionNumbersString(FName,sv) then Result:=sv else Result:='1.0';
  end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result:=False;
  case PageID of
  wpLicense: Result:= IsUpdate();
  wpInfoBefore: Result:= IsUpdate();
  wpSelectTasks: Result:= IsUpdate();
  wpInfoAfter: Result:= IsUpdate();
  wpReady: Result:= IsUpdate();
  end;
end;

procedure InitializeWizard();
begin
  if IsUpdate() then begin
    WizardForm.WelcomeLabel2.Caption:=CustomMessage('Update')+#13#10#13#10+CustomMessage('StartUpdate');
  end;
end;