Updated Innosetup file

Updated Innosetup file

#define MyAppName "WinMute"
#define MyAppVersion "2.1.2.0"
#define MyAppPublisher "LX-Systems"
#define MyAppURL "https://www.lx-s.de/winmute"
#define MyAppExeName "WinMute.exe"
#define MyAppMutex "LxSystemsWinMute"

[Setup]
AppId={{D2E8F9EF-11E7-418B-B9B7-A35A69A30490}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppPublisher}\{#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=..\bin\license.txt
InfoBeforeFile=info-before.txt
AppMutex={#MyAppMutex}
SetupMutex={#MyAppMutex}Setup
PrivilegesRequiredOverridesAllowed=dialog
PrivilegesRequired=lowest
OutputDir=..\bin\
OutputBaseFilename=WinMuteSetup
SetupIconFile=..\..\WinMute\icons\app.ico
UninstallDisplayIcon={app}\{#MyAppExeName}.exe
ArchitecturesInstallIn64BitMode=x64
Compression=lzma
SolidCompression=yes
WizardStyle=modern
ShowLanguageDialog=auto

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "de"; MessagesFile: "compiler:Languages\German.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "autostart" ; Description: "Start WinMute when you log on" ; GroupDescription: "Autostart"; Flags: unchecked

[Files]
Source: "..\bin\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\changelog.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\license.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\liesmich.html"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\readme.html"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\ScreensaverNotify.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\ScreensaverNotify32.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\ScreensaverProxy32.exe"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Registry]
Root: HKCU; Subkey: "Software\lx-systems"; Flags: uninsdeletekeyifempty
Root: HKCU; Subkey: "Software\lx-systems\WinMute"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\lx-systems\WinMute"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
Root: HKCU; Subkey: "Software\lx-systems\WinMute\BluetoothDevices"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\lx-systems\WinMute\WifiNetworks"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "LX-Systems WinMute"; ValueData: "{app}\{#MyAppExeName}"; Tasks: autostart

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

#define MyAppName "WinMute"
#define MyAppVersion "2.1.1.0"
#define MyAppPublisher "LX-Systems"
#define MyAppURL "https://www.lx-s.de/winmute"
#define MyAppExeName "WinMute.exe"

[Setup]
AppId={{D2E8F9EF-11E7-418B-B9B7-A35A69A30490}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppPublisher}\{#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=..\bin\license.txt
InfoBeforeFile=info-before.txt
PrivilegesRequiredOverridesAllowed=dialog
PrivilegesRequired=lowest
OutputDir=..\bin\
OutputBaseFilename=WinMute-Setup
SetupIconFile=..\..\WinMute\icons\app.ico
ArchitecturesInstallIn64BitMode=x64
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "de"; MessagesFile: "compiler:Languages\German.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "autostart" ; Description: "Start WinMute when you log on" ; GroupDescription: "Autostart"; Flags: unchecked

[Files]
Source: "..\bin\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\changelog.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\license.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\liesmich.html"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\readme.html"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\ScreensaverNotify.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\ScreensaverNotify32.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\ScreensaverProxy32.exe"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Registry]
Root: HKCU; Subkey: "Software\lx-systems"; Flags: uninsdeletekeyifempty
Root: HKCU; Subkey: "Software\lx-systems\WinMute"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\lx-systems\WinMute"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
Root: HKCU; Subkey: "Software\lx-systems\WinMute\BluetoothDevices"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\lx-systems\WinMute\WifiNetworks"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "LX-Systems WinMute"; ValueData: "{app}\{#MyAppExeName}"; Tasks: autostart

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent


inno branch: add a check for the binaries before compiling the installer

git-svn-id: f16454573dab46aadd183befef919c0955fb6fd5@635 28bd50df-7adb-d945-0439-6e466c6a13cc

;* Notepad2-mod - Installer script
;*
;* Copyright (C) 2010-2011 XhmikosR
;*
;* This file is part of Notepad2-mod.
;*
;* See License.txt for details.

; Requirements:
; Inno Setup v5.4.2(+): http://www.jrsoftware.org/isdl.php

; $Id$

;#define ICL12
;#define VS2010
;#define WDK

; Preprocessor related stuff
#if VER < 0x05040200
  #error Update your Inno Setup version
#endif

#if !defined(ICL12) && !defined(VS2010) && !defined(WDK)
  #error You need to define ICL12 or VS2010 or WDK first
#endif

#if defined(ICL12) && (defined(VS2010) || defined(WDK))
  #error You can't define ICL12 and at the same time
#endif

#if defined(VS2010) && ( defined(ICL12) || defined(WDK))
  #error You can't define WDK and at the same time
#endif

#if defined(WDK) && (defined(ICL12) || defined(VS2010))
  #error You can't use two defines at the same time
#endif

#if defined(ICL12)
  #define compiler "ICL12"
  #define sse2_required
#elif defined(VS2010)
  #define compiler "VS2010"
#elif defined(WDK)
  #define compiler "WDK"
#endif

#define bindir       "..\bin\" + compiler

#ifnexist SourcePath + bindir + "\Release_x86\Notepad2.exe"
  #error Compile Notepad2 x86 first
#endif

#ifnexist SourcePath + bindir + "\Release_x64\Notepad2.exe"
  #error Compile Notepad2 x64 first
#endif

#define VerMajor
#define VerMinor
#define VerBuild
#define VerRevision

#expr ParseVersion(bindir + "\Release_x86\Notepad2.exe", VerMajor, VerMinor, VerBuild, VerRevision)
#define app_version  str(VerMajor) + "." + str(VerMinor) + "." + str(VerBuild) + "." + str(VerRevision)
#define app_name     "Notepad2-mod"
#define quick_launch "{userappdata}\Microsoft\Internet Explorer\Quick Launch"
#define IFEO         "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe"

[Setup]
AppId={#app_name}
AppName={#app_name}
AppVersion={#app_version}
AppVerName={#app_name} {#app_version}
AppPublisher=XhmikosR
AppPublisherURL=http://code.google.com/p/notepad2-mod/
AppSupportURL=http://code.google.com/p/notepad2-mod/
AppUpdatesURL=http://code.google.com/p/notepad2-mod/
AppContact=http://code.google.com/p/notepad2-mod/
AppCopyright=Copyright  2004-2011, Florian Balmer et all
VersionInfoCompany=XhmikosR
VersionInfoCopyright=Copyright  2004-2011, Florian Balmer et all
VersionInfoDescription={#app_name} {#app_version} Setup
VersionInfoTextVersion={#app_version}
VersionInfoVersion={#app_version}
VersionInfoProductName={#app_name}
VersionInfoProductVersion={#app_version}
VersionInfoProductTextVersion={#app_version}
UninstallDisplayIcon={app}\Notepad2.exe
UninstallDisplayName={#app_name} {#app_version} ({#compiler})
DefaultDirName={pf}\Notepad2
LicenseFile=license.txt
OutputDir=.
OutputBaseFilename={#app_name}.{#app_version}_{#compiler}
SetupIconFile=Setup.ico
WizardImageFile=compiler:WizModernImage-IS.bmp
WizardSmallImageFile=WizardSmallImageFile.bmp
SolidCompression=yes
EnableDirDoesntExistWarning=no
AllowNoIcons=yes
ShowTasksTreeLines=yes
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyPage=yes
DisableWelcomePage=yes
AllowCancelDuringInstall=no
#if defined(ICL12) || defined(VS2010) || defined(USE_MSVC2010)
MinVersion=0,5.1.2600sp3
#else
MinVersion=0,5.0
#endif
ArchitecturesAllowed=x86 x64
ArchitecturesInstallIn64BitMode=x64

[Languages]
Name: en; MessagesFile: compiler:Default.isl

[Messages]
BeveledLabel     ={#app_name} {#app_version}  -  Compiled with {#compiler}
SetupAppTitle    =Setup - {#app_name}
SetupWindowTitle =Setup - {#app_name}

[CustomMessages]
en.msg_AppIsRunning          =Setup has detected that {#app_name} is currently running.%n%nPlease close all instances of it now, then click OK to continue, or Cancel to exit.
en.msg_AppIsRunningUninstall =Uninstall has detected that {#app_name} is currently running.%n%nPlease close all instances of it now, then click OK to continue, or Cancel to exit.
en.msg_DeleteSettings        =Do you also want to delete {#app_name}'s settings?%n%nIf you plan on installing {#app_name} again then you do not have to delete them.
en.msg_SetupIsRunningWarning ={#app_name} setup is already running!
#if defined(sse_required)
en.msg_simd_sse              =This build of {#app_name} requires a CPU with SSE extension support.%n%nYour CPU does not have those capabilities.
#elif defined(sse2_required)
en.msg_simd_sse2             =This build of {#app_name} requires a CPU with SSE2 extension support.%n%nYour CPU does not have those capabilities.
#endif
en.tsk_AllUsers              =For all users
en.tsk_CurrentUser           =For the current user only
en.tsk_Other                 =Other tasks:
en.tsk_ResetSettings         =Reset {#app_name}'s settings
en.tsk_RemoveDefault         =Restore Windows notepad
en.tsk_SetDefault            =Replace Windows notepad with {#app_name}

[Tasks]
Name: desktopicon;        Description: {cm:CreateDesktopIcon};     GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
Name: desktopicon\user;   Description: {cm:tsk_CurrentUser};       GroupDescription: {cm:AdditionalIcons}; Flags: unchecked exclusive
Name: desktopicon\common; Description: {cm:tsk_AllUsers};          GroupDescription: {cm:AdditionalIcons}; Flags: unchecked exclusive
Name: quicklaunchicon;    Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked;             OnlyBelowVersion: 0,6.01
Name: reset_settings;     Description: {cm:tsk_ResetSettings};     GroupDescription: {cm:tsk_Other};       Flags: checkedonce unchecked; Check: SettingsExistCheck()
Name: set_default;        Description: {cm:tsk_SetDefault};        GroupDescription: {cm:tsk_Other};                                     Check: not DefaulNotepadCheck()
Name: remove_default;     Description: {cm:tsk_RemoveDefault};     GroupDescription: {cm:tsk_Other};       Flags: checkedonce unchecked; Check: DefaulNotepadCheck()

[Files]
Source: psvince.dll;                        DestDir: {app};                  Flags: ignoreversion
Source: ..\License.txt;                     DestDir: {app};                  Flags: ignoreversion
Source: {#bindir}\Release_x64\Notepad2.exe; DestDir: {app};                  Flags: ignoreversion;                         Check: Is64BitInstallMode()
Source: {#bindir}\Release_x86\Notepad2.exe; DestDir: {app};                  Flags: ignoreversion;                         Check: not Is64BitInstallMode()
Source: Notepad2.ini;                       DestDir: {userappdata}\Notepad2; Flags: onlyifdoesntexist uninsneveruninstall
Source: ..\Notepad2.txt;                    DestDir: {app};                  Flags: ignoreversion
Source: ..\Readme.txt;                      DestDir: {app};                  Flags: ignoreversion
Source: ..\Readme-mod.txt;                  DestDir: {app};                  Flags: ignoreversion

[Icons]
Name: {commondesktop}\{#app_name}; Filename: {app}\Notepad2.exe; Tasks: desktopicon\common; Comment: {#app_name} {#app_version}; WorkingDir: {app}; AppUserModelID: Notepad2; IconFilename: {app}\Notepad2.exe; IconIndex: 0
Name: {userdesktop}\{#app_name};   Filename: {app}\Notepad2.exe; Tasks: desktopicon\user;   Comment: {#app_name} {#app_version}; WorkingDir: {app}; AppUserModelID: Notepad2; IconFilename: {app}\Notepad2.exe; IconIndex: 0
Name: {#quick_launch}\{#app_name}; Filename: {app}\Notepad2.exe; Tasks: quicklaunchicon;    Comment: {#app_name} {#app_version}; WorkingDir: {app};                           IconFilename: {app}\Notepad2.exe; IconIndex: 0

[INI]
Filename: {app}\Notepad2.ini; Section: Notepad2; Key: Notepad2.ini; String: %APPDATA%\Notepad2\Notepad2.ini

[Run]
Filename: {app}\Notepad2.exe; Description: {cm:LaunchProgram,{#app_name}}; WorkingDir: {app}; Flags: nowait postinstall skipifsilent unchecked

[InstallDelete]
Type: files;      Name: {userdesktop}\{#app_name}.lnk;   Check: not IsTaskSelected('desktopicon\user')   and IsUpgrade()
Type: files;      Name: {commondesktop}\{#app_name}.lnk; Check: not IsTaskSelected('desktopicon\common') and IsUpgrade()
Type: files;      Name: {#quick_launch}\{#app_name}.lnk; Check: not IsTaskSelected('quicklaunchicon')    and IsUpgrade(); OnlyBelowVersion: 0,6.01
Type: files;      Name: {app}\Notepad2.ini;              Check: IsUpgrade()

[UninstallDelete]
Type: files;      Name: {app}\Notepad2.ini
Type: dirifempty; Name: {app}

[Code]
// Global variables/constants and general functions
const installer_mutex_name = '{#app_name}' + '_setup_mutex';

function IsModuleLoaded(modulename: AnsiString): Boolean;
external 'IsModuleLoaded2@files:psvince.dll stdcall setuponly';

function IsModuleLoadedU(modulename: AnsiString): Boolean;
external 'IsModuleLoaded2@{app}\psvince.dll stdcall uninstallonly';

#if defined(sse_required) || defined(sse2_required)
function IsProcessorFeaturePresent(Feature: Integer): Boolean;
external 'IsProcessorFeaturePresent@kernel32.dll stdcall';
#endif

////////////////////////////////////////
//  Custom functions and procedures   //
////////////////////////////////////////

// Check if Notepad2 has replaced Windows Notepad
function DefaulNotepadCheck(): Boolean;
var
  sDebugger: String;
begin
  if RegQueryStringValue(HKLM, '{#IFEO}', 'Debugger', sDebugger) then begin
    if sDebugger = (ExpandConstant('"{app}\Notepad2.exe" /z')) then begin
      Log('Custom Code: {#app_name} is set as the default notepad');
      Result := True;
    end
    else begin
      Log('Custom Code: {#app_name} is NOT set as the default notepad');
      Result := False;
    end;
  end;
end;

#if defined(sse_required)
function Is_SSE_Supported(): Boolean;
begin
  // PF_XMMI_INSTRUCTIONS_AVAILABLE
  Result := IsProcessorFeaturePresent(6);
end;

#elif defined(sse2_required)

function Is_SSE2_Supported(): Boolean;
begin
  // PF_XMMI64_INSTRUCTIONS_AVAILABLE
  Result := IsProcessorFeaturePresent(10);
end;

#endif

function IsOldBuildInstalled(): Boolean;
begin
  if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Notepad2') and
  FileExists(ExpandConstant('{pf}\Notepad2\Uninstall.inf')) then begin
    Log('Custom Code: The old build is installed');
    Result := True;
  end
  else begin
    Log('Custom Code: The old build is NOT installed');
    Result := False;
  end;
end;

function IsUpgrade(): Boolean;
var
  sPrevPath: String;
begin
  sPrevPath := WizardForm.PrevAppDir;
  Result := (sPrevPath <> '');
end;

// Check if Notepad2's settings exist
function SettingsExistCheck(): Boolean;
begin
  if FileExists(ExpandConstant('{userappdata}\Notepad2\Notepad2.ini')) then begin
    Log('Custom Code: Settings are present');
    Result := True;
  end
  else begin
    Log('Custom Code: Settings are NOT present');
    Result := False;
  end;
end;

function UninstallOldVersion(): Integer;
var
  iResultCode: Integer;
begin
  // Return Values:
  // 0 - no idea
  // 1 - error executing the command
  // 2 - successfully executed the command

  // default return value
  Log('Custom Code: Will try to uninstall the old build');
  Result := 0;
    if Exec('rundll32.exe', ExpandConstant('advpack.dll,LaunchINFSectionEx "{pf}\Notepad2\Uninstall.inf",DefaultUninstall,,8,N'), '', SW_HIDE, ewWaitUntilTerminated, iResultCode) then begin
      Result := 2;
      Sleep(500);
      Log('Custom Code: The old build was successfully uninstalled');
    end
    else begin
      Result := 1;
      Log('Custom Code: Something went wrong when uninstalling the old build');
    end;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // Hide the license page
  if IsUpgrade() and (PageID = wpLicense) then begin
    Result := True;
  end
  else begin
    Result := False;
  end;
end;

procedure AddReg();
begin
  RegWriteStringValue(HKCR, 'Applications\notepad2.exe', 'AppUserModelID', 'Notepad2');
  RegWriteStringValue(HKCR, 'Applications\notepad2.exe\shell\open\command', '', ExpandConstant('"{app}\Notepad2.exe" %1'));
  RegWriteStringValue(HKCR, '*\OpenWithList\notepad2.exe', '', '');
end;

procedure RemoveReg();
begin
  RegDeleteKeyIncludingSubkeys(HKCR, 'Applications\notepad2.exe');
  RegDeleteKeyIncludingSubkeys(HKCR, '*\OpenWithList\notepad2.exe');
end;

procedure CleanUpSettings();
begin
  DeleteFile(ExpandConstant('{userappdata}\Notepad2\Notepad2.ini'));
  RemoveDir(ExpandConstant('{userappdata}\Notepad2'));
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
  else if CurPageID = wpFinished then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish)
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin

  if CurStep = ssInstall then begin
    if IsOldBuildInstalled() then begin
      UninstallOldVersion();
      // This is the case where the old build is installed; the DefaulNotepadCheck() returns true
      // and the set_default task isn't selected
      if not IsTaskSelected('remove_default') then begin
        RegWriteStringValue(HKLM, '{#IFEO}', 'Debugger', ExpandConstant('"{app}\Notepad2.exe" /z'));
      end;

    end;
  end;

  if CurStep = ssPostInstall then begin
    if IsTaskSelected('reset_settings') then begin
      CleanUpSettings();
    end;

    if IsTaskSelected('set_default') then begin
      RegWriteStringValue(HKLM, '{#IFEO}', 'Debugger', ExpandConstant('"{app}\Notepad2.exe" /z'));
    end;

    if IsTaskSelected('remove_default') then begin
      RegDeleteValue(HKLM, '{#IFEO}', 'Debugger');
      RegDeleteKeyIfEmpty(HKLM, '{#IFEO}');
    end;

    // Always add Notepad2's AppUserModelID and the rest registry values
    AddReg();
  end;

end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  // When uninstalling, ask the user to delete Notepad2's settings and logs
  if CurUninstallStep = usUninstall then begin
    if SettingsExistCheck() then begin
      if SuppressibleMsgBox(CustomMessage('msg_DeleteSettings'), mbConfirmation, MB_YESNO or MB_DEFBUTTON2, IDNO) = IDYES then begin
        CleanUpSettings();
      end;
    end;

    RegDeleteValue(HKLM, '{#IFEO}', 'Debugger');
    RegDeleteKeyIfEmpty(HKLM, '{#IFEO}');
    RemoveReg();

  end;
end;

procedure InitializeWizard();
begin
  WizardForm.SelectTasksLabel.Hide;
  WizardForm.TasksList.Top    := 0;
  WizardForm.TasksList.Height := PageFromID(wpSelectTasks).SurfaceHeight;
end;

function InitializeSetup(): Boolean;
var
  iMsgBoxResult: Integer;
begin
  // Create a mutex for the installer and if it's already running then show a message and stop installation
  if CheckForMutexes(installer_mutex_name) and not WizardSilent() then begin
    SuppressibleMsgBox(CustomMessage('msg_SetupIsRunningWarning'), mbError, MB_OK, MB_OK);
    Result := False;
  end
  else begin
    Result := True;
    CreateMutex(installer_mutex_name);

    while IsModuleLoaded('Notepad2.exe') and (iMsgBoxResult <> IDCANCEL) do begin
      iMsgBoxResult := SuppressibleMsgBox(CustomMessage('msg_AppIsRunning'), mbError, MB_OKCANCEL, IDCANCEL);
    end;

    if iMsgBoxResult = IDCANCEL then begin
      Result := False;
    end;

#if defined(sse2_required)
    if not Is_SSE2_Supported() then begin
      SuppressibleMsgBox(CustomMessage('msg_simd_sse2'), mbCriticalError, MB_OK, MB_OK);
      Result := False;
    end;
#elif defined(sse_required)
    if not Is_SSE_Supported() then begin
      SuppressibleMsgBox(CustomMessage('msg_simd_sse'), mbCriticalError, MB_OK, MB_OK);
      Result := False;
    end;
#endif

  end;
end;

function InitializeUninstall(): Boolean;
var
  iMsgBoxResult: Integer;
begin
  if CheckForMutexes(installer_mutex_name) then begin
    SuppressibleMsgBox(CustomMessage('msg_SetupIsRunningWarning'), mbError, MB_OK, MB_OK);
    Result := False;
  end
  else begin
    Result := True;
    CreateMutex(installer_mutex_name);

    // Check if app is running during uninstallation
    while IsModuleLoadedU('Notepad2.exe') and (iMsgBoxResult <> IDCANCEL) do begin
      iMsgBoxResult := SuppressibleMsgBox(CustomMessage('msg_AppIsRunningUninstall'), mbError, MB_OKCANCEL, IDCANCEL);
    end;

    if iMsgBoxResult = IDCANCEL then begin
      Result := False;
    end;

    // Unload the psvince.dll in order to be uninstalled
    UnloadDLL(ExpandConstant('{app}\psvince.dll'));
  end;
end;

;* Notepad2-mod - Installer script
;*
;* Copyright (C) 2010-2011 XhmikosR
;*
;* This file is part of Notepad2-mod.
;*
;* See License.txt for details.

; Requirements:
; Inno Setup v5.4.2(+): http://www.jrsoftware.org/isdl.php

; $Id$

;#define ICL12
;#define VS2010
;#define WDK

; Preprocessor related stuff
#if VER < 0x05040200
  #error Update your Inno Setup version
#endif

#if !defined(ICL12) && !defined(VS2010) && !defined(WDK)
  #error You need to define ICL12 or VS2010 or WDK first
#endif

#if defined(ICL12) && (defined(VS2010) || defined(WDK))
  #error You can't define ICL12 and at the same time
#endif

#if defined(VS2010) && ( defined(ICL12) || defined(WDK))
  #error You can't define WDK and at the same time
#endif

#if defined(WDK) && (defined(ICL12) || defined(VS2010))
  #error You can't use two defines at the same time
#endif

#if defined(ICL12)
  #define compiler "ICL12"
  #define sse2_required
#elif defined(VS2010)
  #define compiler "VS2010"
#elif defined(WDK)
  #define compiler "WDK"
#endif

#define bindir     "..\bin\" + compiler

#define VerMajor
#define VerMinor
#define VerBuild
#define VerRevision

#expr ParseVersion(bindir + "\Release_x86\Notepad2.exe", VerMajor, VerMinor, VerBuild, VerRevision)
#define app_version  str(VerMajor) + "." + str(VerMinor) + "." + str(VerBuild) + "." + str(VerRevision)
#define app_name     "Notepad2-mod"
#define quick_launch "{userappdata}\Microsoft\Internet Explorer\Quick Launch"
#define IFEO         "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe"

[Setup]
AppId={#app_name}
AppName={#app_name}
AppVersion={#app_version}
AppVerName={#app_name} {#app_version}
AppPublisher=XhmikosR
AppPublisherURL=http://code.google.com/p/notepad2-mod/
AppSupportURL=http://code.google.com/p/notepad2-mod/
AppUpdatesURL=http://code.google.com/p/notepad2-mod/
AppContact=http://code.google.com/p/notepad2-mod/
AppCopyright=Copyright  2004-2011, Florian Balmer et all
VersionInfoCompany=XhmikosR
VersionInfoCopyright=Copyright  2004-2011, Florian Balmer et all
VersionInfoDescription={#app_name} {#app_version} Setup
VersionInfoTextVersion={#app_version}
VersionInfoVersion={#app_version}
VersionInfoProductName={#app_name}
VersionInfoProductVersion={#app_version}
VersionInfoProductTextVersion={#app_version}
UninstallDisplayIcon={app}\Notepad2.exe
UninstallDisplayName={#app_name} {#app_version} ({#compiler})
DefaultDirName={pf}\Notepad2
LicenseFile=license.txt
OutputDir=.
OutputBaseFilename={#app_name}.{#app_version}_{#compiler}
SetupIconFile=Setup.ico
WizardImageFile=compiler:WizModernImage-IS.bmp
WizardSmallImageFile=WizardSmallImageFile.bmp
SolidCompression=yes
EnableDirDoesntExistWarning=no
AllowNoIcons=yes
ShowTasksTreeLines=yes
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyPage=yes
DisableWelcomePage=yes
AllowCancelDuringInstall=no
#if defined(ICL12) || defined(VS2010) || defined(USE_MSVC2010)
MinVersion=0,5.1.2600sp3
#else
MinVersion=0,5.0
#endif
ArchitecturesAllowed=x86 x64
ArchitecturesInstallIn64BitMode=x64

[Languages]
Name: en; MessagesFile: compiler:Default.isl

[Messages]
BeveledLabel     ={#app_name} {#app_version}  -  Compiled with {#compiler}
SetupAppTitle    =Setup - {#app_name}
SetupWindowTitle =Setup - {#app_name}

[CustomMessages]
en.msg_AppIsRunning          =Setup has detected that {#app_name} is currently running.%n%nPlease close all instances of it now, then click OK to continue, or Cancel to exit.
en.msg_AppIsRunningUninstall =Uninstall has detected that {#app_name} is currently running.%n%nPlease close all instances of it now, then click OK to continue, or Cancel to exit.
en.msg_DeleteSettings        =Do you also want to delete {#app_name}'s settings?%n%nIf you plan on installing {#app_name} again then you do not have to delete them.
en.msg_SetupIsRunningWarning ={#app_name} setup is already running!
#if defined(sse_required)
en.msg_simd_sse              =This build of {#app_name} requires a CPU with SSE extension support.%n%nYour CPU does not have those capabilities.
#elif defined(sse2_required)
en.msg_simd_sse2             =This build of {#app_name} requires a CPU with SSE2 extension support.%n%nYour CPU does not have those capabilities.
#endif
en.tsk_AllUsers              =For all users
en.tsk_CurrentUser           =For the current user only
en.tsk_Other                 =Other tasks:
en.tsk_ResetSettings         =Reset {#app_name}'s settings
en.tsk_RemoveDefault         =Restore Windows notepad
en.tsk_SetDefault            =Replace Windows notepad with {#app_name}

[Tasks]
Name: desktopicon;        Description: {cm:CreateDesktopIcon};     GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
Name: desktopicon\user;   Description: {cm:tsk_CurrentUser};       GroupDescription: {cm:AdditionalIcons}; Flags: unchecked exclusive
Name: desktopicon\common; Description: {cm:tsk_AllUsers};          GroupDescription: {cm:AdditionalIcons}; Flags: unchecked exclusive
Name: quicklaunchicon;    Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked;             OnlyBelowVersion: 0,6.01
Name: reset_settings;     Description: {cm:tsk_ResetSettings};     GroupDescription: {cm:tsk_Other};       Flags: checkedonce unchecked; Check: SettingsExistCheck()
Name: set_default;        Description: {cm:tsk_SetDefault};        GroupDescription: {cm:tsk_Other};                                     Check: not DefaulNotepadCheck()
Name: remove_default;     Description: {cm:tsk_RemoveDefault};     GroupDescription: {cm:tsk_Other};       Flags: checkedonce unchecked; Check: DefaulNotepadCheck()

[Files]
Source: psvince.dll;                        DestDir: {app};                  Flags: ignoreversion
Source: ..\License.txt;                     DestDir: {app};                  Flags: ignoreversion
Source: {#bindir}\Release_x64\Notepad2.exe; DestDir: {app};                  Flags: ignoreversion;                         Check: Is64BitInstallMode()
Source: {#bindir}\Release_x86\Notepad2.exe; DestDir: {app};                  Flags: ignoreversion;                         Check: not Is64BitInstallMode()
Source: Notepad2.ini;                       DestDir: {userappdata}\Notepad2; Flags: onlyifdoesntexist uninsneveruninstall
Source: ..\Notepad2.txt;                    DestDir: {app};                  Flags: ignoreversion
Source: ..\Readme.txt;                      DestDir: {app};                  Flags: ignoreversion
Source: ..\Readme-mod.txt;                  DestDir: {app};                  Flags: ignoreversion

[Icons]
Name: {commondesktop}\{#app_name}; Filename: {app}\Notepad2.exe; Tasks: desktopicon\common; Comment: {#app_name} {#app_version}; WorkingDir: {app}; AppUserModelID: Notepad2; IconFilename: {app}\Notepad2.exe; IconIndex: 0
Name: {userdesktop}\{#app_name};   Filename: {app}\Notepad2.exe; Tasks: desktopicon\user;   Comment: {#app_name} {#app_version}; WorkingDir: {app}; AppUserModelID: Notepad2; IconFilename: {app}\Notepad2.exe; IconIndex: 0
Name: {#quick_launch}\{#app_name}; Filename: {app}\Notepad2.exe; Tasks: quicklaunchicon;    Comment: {#app_name} {#app_version}; WorkingDir: {app};                           IconFilename: {app}\Notepad2.exe; IconIndex: 0

[INI]
Filename: {app}\Notepad2.ini; Section: Notepad2; Key: Notepad2.ini; String: %APPDATA%\Notepad2\Notepad2.ini

[Run]
Filename: {app}\Notepad2.exe; Description: {cm:LaunchProgram,{#app_name}}; WorkingDir: {app}; Flags: nowait postinstall skipifsilent unchecked

[InstallDelete]
Type: files;      Name: {userdesktop}\{#app_name}.lnk;   Check: not IsTaskSelected('desktopicon\user')   and IsUpgrade()
Type: files;      Name: {commondesktop}\{#app_name}.lnk; Check: not IsTaskSelected('desktopicon\common') and IsUpgrade()
Type: files;      Name: {#quick_launch}\{#app_name}.lnk; Check: not IsTaskSelected('quicklaunchicon')    and IsUpgrade(); OnlyBelowVersion: 0,6.01
Type: files;      Name: {app}\Notepad2.ini;              Check: IsUpgrade()

[UninstallDelete]
Type: files;      Name: {app}\Notepad2.ini
Type: dirifempty; Name: {app}

[Code]
// Global variables/constants and general functions
const installer_mutex_name = '{#app_name}' + '_setup_mutex';

function IsModuleLoaded(modulename: AnsiString): Boolean;
external 'IsModuleLoaded2@files:psvince.dll stdcall setuponly';

function IsModuleLoadedU(modulename: AnsiString): Boolean;
external 'IsModuleLoaded2@{app}\psvince.dll stdcall uninstallonly';

#if defined(sse_required) || defined(sse2_required)
function IsProcessorFeaturePresent(Feature: Integer): Boolean;
external 'IsProcessorFeaturePresent@kernel32.dll stdcall';
#endif

////////////////////////////////////////
//  Custom functions and procedures   //
////////////////////////////////////////

// Check if Notepad2 has replaced Windows Notepad
function DefaulNotepadCheck(): Boolean;
var
  sDebugger: String;
begin
  if RegQueryStringValue(HKLM, '{#IFEO}', 'Debugger', sDebugger) then begin
    if sDebugger = (ExpandConstant('"{app}\Notepad2.exe" /z')) then begin
      Log('Custom Code: {#app_name} is set as the default notepad');
      Result := True;
    end
    else begin
      Log('Custom Code: {#app_name} is NOT set as the default notepad');
      Result := False;
    end;
  end;
end;

#if defined(sse_required)
function Is_SSE_Supported(): Boolean;
begin
  // PF_XMMI_INSTRUCTIONS_AVAILABLE
  Result := IsProcessorFeaturePresent(6);
end;

#elif defined(sse2_required)

function Is_SSE2_Supported(): Boolean;
begin
  // PF_XMMI64_INSTRUCTIONS_AVAILABLE
  Result := IsProcessorFeaturePresent(10);
end;

#endif

function IsOldBuildInstalled(): Boolean;
begin
  if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Notepad2') and
  FileExists(ExpandConstant('{pf}\Notepad2\Uninstall.inf')) then begin
    Log('Custom Code: The old build is installed');
    Result := True;
  end
  else begin
    Log('Custom Code: The old build is NOT installed');
    Result := False;
  end;
end;

function IsUpgrade(): Boolean;
var
  sPrevPath: String;
begin
  sPrevPath := WizardForm.PrevAppDir;
  Result := (sPrevPath <> '');
end;

// Check if Notepad2's settings exist
function SettingsExistCheck(): Boolean;
begin
  if FileExists(ExpandConstant('{userappdata}\Notepad2\Notepad2.ini')) then begin
    Log('Custom Code: Settings are present');
    Result := True;
  end
  else begin
    Log('Custom Code: Settings are NOT present');
    Result := False;
  end;
end;

function UninstallOldVersion(): Integer;
var
  iResultCode: Integer;
begin
  // Return Values:
  // 0 - no idea
  // 1 - error executing the command
  // 2 - successfully executed the command

  // default return value
  Log('Custom Code: Will try to uninstall the old build');
  Result := 0;
    if Exec('rundll32.exe', ExpandConstant('advpack.dll,LaunchINFSectionEx "{pf}\Notepad2\Uninstall.inf",DefaultUninstall,,8,N'), '', SW_HIDE, ewWaitUntilTerminated, iResultCode) then begin
      Result := 2;
      Sleep(500);
      Log('Custom Code: The old build was successfully uninstalled');
    end
    else begin
      Result := 1;
      Log('Custom Code: Something went wrong when uninstalling the old build');
    end;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // Hide the license page
  if IsUpgrade() and (PageID = wpLicense) then begin
    Result := True;
  end
  else begin
    Result := False;
  end;
end;

procedure AddReg();
begin
  RegWriteStringValue(HKCR, 'Applications\notepad2.exe', 'AppUserModelID', 'Notepad2');
  RegWriteStringValue(HKCR, 'Applications\notepad2.exe\shell\open\command', '', ExpandConstant('"{app}\Notepad2.exe" %1'));
  RegWriteStringValue(HKCR, '*\OpenWithList\notepad2.exe', '', '');
end;

procedure RemoveReg();
begin
  RegDeleteKeyIncludingSubkeys(HKCR, 'Applications\notepad2.exe');
  RegDeleteKeyIncludingSubkeys(HKCR, '*\OpenWithList\notepad2.exe');
end;

procedure CleanUpSettings();
begin
  DeleteFile(ExpandConstant('{userappdata}\Notepad2\Notepad2.ini'));
  RemoveDir(ExpandConstant('{userappdata}\Notepad2'));
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
  else if CurPageID = wpFinished then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish)
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin

  if CurStep = ssInstall then begin
    if IsOldBuildInstalled() then begin
      UninstallOldVersion();
      // This is the case where the old build is installed; the DefaulNotepadCheck() returns true
      // and the set_default task isn't selected
      if not IsTaskSelected('remove_default') then begin
        RegWriteStringValue(HKLM, '{#IFEO}', 'Debugger', ExpandConstant('"{app}\Notepad2.exe" /z'));
      end;

    end;
  end;

  if CurStep = ssPostInstall then begin
    if IsTaskSelected('reset_settings') then begin
      CleanUpSettings();
    end;

    if IsTaskSelected('set_default') then begin
      RegWriteStringValue(HKLM, '{#IFEO}', 'Debugger', ExpandConstant('"{app}\Notepad2.exe" /z'));
    end;

    if IsTaskSelected('remove_default') then begin
      RegDeleteValue(HKLM, '{#IFEO}', 'Debugger');
      RegDeleteKeyIfEmpty(HKLM, '{#IFEO}');
    end;

    // Always add Notepad2's AppUserModelID and the rest registry values
    AddReg();
  end;

end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  // When uninstalling, ask the user to delete Notepad2's settings and logs
  if CurUninstallStep = usUninstall then begin
    if SettingsExistCheck() then begin
      if SuppressibleMsgBox(CustomMessage('msg_DeleteSettings'), mbConfirmation, MB_YESNO or MB_DEFBUTTON2, IDNO) = IDYES then begin
        CleanUpSettings();
      end;
    end;

    RegDeleteValue(HKLM, '{#IFEO}', 'Debugger');
    RegDeleteKeyIfEmpty(HKLM, '{#IFEO}');
    RemoveReg();

  end;
end;

procedure InitializeWizard();
begin
  WizardForm.SelectTasksLabel.Hide;
  WizardForm.TasksList.Top    := 0;
  WizardForm.TasksList.Height := PageFromID(wpSelectTasks).SurfaceHeight;
end;

function InitializeSetup(): Boolean;
var
  iMsgBoxResult: Integer;
begin
  // Create a mutex for the installer and if it's already running then show a message and stop installation
  if CheckForMutexes(installer_mutex_name) and not WizardSilent() then begin
    SuppressibleMsgBox(CustomMessage('msg_SetupIsRunningWarning'), mbError, MB_OK, MB_OK);
    Result := False;
  end
  else begin
    Result := True;
    CreateMutex(installer_mutex_name);

    while IsModuleLoaded('Notepad2.exe') and (iMsgBoxResult <> IDCANCEL) do begin
      iMsgBoxResult := SuppressibleMsgBox(CustomMessage('msg_AppIsRunning'), mbError, MB_OKCANCEL, IDCANCEL);
    end;

    if iMsgBoxResult = IDCANCEL then begin
      Result := False;
    end;

#if defined(sse2_required)
    if not Is_SSE2_Supported() then begin
      SuppressibleMsgBox(CustomMessage('msg_simd_sse2'), mbCriticalError, MB_OK, MB_OK);
      Result := False;
    end;
#elif defined(sse_required)
    if not Is_SSE_Supported() then begin
      SuppressibleMsgBox(CustomMessage('msg_simd_sse'), mbCriticalError, MB_OK, MB_OK);
      Result := False;
    end;
#endif

  end;
end;

function InitializeUninstall(): Boolean;
var
  iMsgBoxResult: Integer;
begin
  if CheckForMutexes(installer_mutex_name) then begin
    SuppressibleMsgBox(CustomMessage('msg_SetupIsRunningWarning'), mbError, MB_OK, MB_OK);
    Result := False;
  end
  else begin
    Result := True;
    CreateMutex(installer_mutex_name);

    // Check if app is running during uninstallation
    while IsModuleLoadedU('Notepad2.exe') and (iMsgBoxResult <> IDCANCEL) do begin
      iMsgBoxResult := SuppressibleMsgBox(CustomMessage('msg_AppIsRunningUninstall'), mbError, MB_OKCANCEL, IDCANCEL);
    end;

    if iMsgBoxResult = IDCANCEL then begin
      Result := False;
    end;

    // Unload the psvince.dll in order to be uninstalled
    UnloadDLL(ExpandConstant('{app}\psvince.dll'));
  end;
end;


Fixed registry value in installer

Fixed registry value in installer

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

[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={{DE3A8FE7-5918-471A-BF59-84C2C3328CCF}
AppName=AutoTest.Net
AppVersion=1.2.0
AppVerName=AutoTest.Net 1.2.0
AppPublisher=AutoTest.Net
DefaultDirName={pf}\AutoTest.Net
DefaultGroupName=AutoTest.Net
LicenseFile=..\ReleaseBinaries\AutoTest.License.txt
OutputDir=..\ReleaseBinaries\Installer
OutputBaseFilename=AutoTest.Net-v1.2.0
Compression=lzma
SolidCompression=yes
Uninstallable=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "..\ReleaseBinaries\AutoTest.Messages.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.Core.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.UI.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.Console.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.License.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.WinForms.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\README"; DestDir: "{app}"; Flags: ignoreversion

Source: "..\ReleaseBinaries\AutoTest.VS.Util.dll"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\AutoTest.VSAddin.dll"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\AutoTest.VSAddin2008.Addin"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\AutoTest.VSAddin2010.Addin"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\VSMenuKiller.exe"; DestDir: "{app}"; Flags: ignoreversion;

Source: "..\ReleaseBinaries\Icons\circleFAIL.png"; DestDir: "{app}\Icons"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Icons\circleWAIL.png"; DestDir: "{app}\Icons"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Icons\circleWIN.png"; DestDir: "{app}\Icons"; Flags: ignoreversion

Source: "..\ReleaseBinaries\AutoTest.TestRunner.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.v4.0.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.v4.0.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.x86.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.x86.v4.0.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.x86.v4.0.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunners.Shared.dll"; DestDir: "{app}"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\NUnit\AutoTest.TestRunners.NUnit.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\NUnit\nunit.core.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\NUnit\nunit.core.interfaces.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\NUnit\nunit.util.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\XUnit\AutoTest.TestRunners.XUnit.dll"; DestDir: "{app}\TestRunners\XUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\XUnit\xunit.runner.utility.dll"; DestDir: "{app}\TestRunners\XUnit"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\MSTest\AutoTest.TestRunners.MSTest.dll"; DestDir: "{app}\TestRunners\MSTest"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MSTest\celer.Core.dll"; DestDir: "{app}\TestRunners\MSTest"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\MSpec\AutoTest.TestRunners.MSpec.dll"; DestDir: "{app}\TestRunners\MSpec"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MSpec\Machine.Specifications.dll"; DestDir: "{app}\TestRunners\MSpec"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\MbUnit\AutoTest.TestRunners.MbUnit.dll"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MbUnit\Gallio.dll"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MbUnit\Gallio.XmlSerializers.dll"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MbUnit\mbunit.config"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion

Source: "..\ReleaseBinaries\Castle.Core.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Castle.Facilities.Logging.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Castle.license.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Castle.Windsor.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Mono.Cecil.dll"; DestDir: "{app}"; Flags: ignoreversion

Source: "..\src\AutoTest.Core\AutoTest.config.template.VS"; DestDir: "{app}"; Flags: ignoreversion

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:UninstallProgram,AutoTest.Net}"; Filename: "{uninstallexe}"

[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\10.0"; ValueType: string; ValueName: ""; ValueData: "AutomationOptions";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\10.0\AutomationOptions"; ValueType: string; ValueName: ""; ValueData: "LookInFolders";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\10.0\AutomationOptions\LookInFolders"; ValueType: string; ValueName: "{app}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\9.0"; ValueType: string; ValueName: ""; ValueData: "AutomationOptions";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\9.0\AutomationOptions"; ValueType: string; ValueName: ""; ValueData: "LookInFolders";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\9.0\AutomationOptions\LookInFolders"; ValueType: string; ValueName: "{app}"; ValueData: ""; Flags: uninsdeletevalue

[Run]
Filename:"{reg:HKLM\SOFTWARE\Microsoft\.NETFramework,InstallRoot}\{reg:HKCR\CLSID\{{61b3e12b-3586-3a58-a497-7ed7c4c794b9%7D\InprocServer32\2.0.0.0,RuntimeVersion}\RegAsm.exe"; Parameters: /codebase AutoTest.VSAddin.dll;WorkingDir: {app}; StatusMsg: "Registeringcontrols ..."; Flags: runhidden;

[UninstallRun]
Filename:"{app}\VSMenuKiller.exe"; Parameters: VisualStudio.DTE.10.0 MenuBar AutoTest.Net;WorkingDir: {app}; StatusMsg: "Removing 2010 addin ..."; Flags: runhidden;
Filename:"{app}\VSMenuKiller.exe"; Parameters: VisualStudio.DTE.9.0 MenuBar AutoTest.Net;WorkingDir: {app}; StatusMsg: "Removing 2008 addin ..."; Flags: runhidden;
Filename:"{reg:HKLM\SOFTWARE\Microsoft\.NETFramework,InstallRoot}\{reg:HKCR\CLSID\{{61b3e12b-3586-3a58-a497-7ed7c4c794b9%7D\InprocServer32\2.0.0.0,RuntimeVersion}\RegAsm.exe"; Parameters: /unregister AutoTest.VSAddin.dll; WorkingDir: {app}; StatusMsg: "Unregisteringcontrols ..."; Flags: runhidden;

[Code]

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

[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={{DE3A8FE7-5918-471A-BF59-84C2C3328CCF}
AppName=AutoTest.Net
AppVersion=1.2.0
AppVerName=AutoTest.Net 1.2.0
AppPublisher=AutoTest.Net
DefaultDirName={pf}\AutoTest.Net
DefaultGroupName=AutoTest.Net
LicenseFile=..\ReleaseBinaries\AutoTest.License.txt
OutputDir=..\ReleaseBinaries\Installer
OutputBaseFilename=AutoTest.Net-v1.2.0
Compression=lzma
SolidCompression=yes
Uninstallable=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "..\ReleaseBinaries\AutoTest.Messages.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.Core.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.UI.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.Console.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.License.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.WinForms.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\README"; DestDir: "{app}"; Flags: ignoreversion

Source: "..\ReleaseBinaries\AutoTest.VS.Util.dll"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\AutoTest.VSAddin.dll"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\AutoTest.VSAddin2008.Addin"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\AutoTest.VSAddin2010.Addin"; DestDir: "{app}"; Flags: ignoreversion;
Source: "..\ReleaseBinaries\VSMenuKiller.exe"; DestDir: "{app}"; Flags: ignoreversion;

Source: "..\ReleaseBinaries\Icons\circleFAIL.png"; DestDir: "{app}\Icons"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Icons\circleWAIL.png"; DestDir: "{app}\Icons"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Icons\circleWIN.png"; DestDir: "{app}\Icons"; Flags: ignoreversion

Source: "..\ReleaseBinaries\AutoTest.TestRunner.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.v4.0.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.v4.0.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.x86.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.x86.v4.0.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunner.x86.v4.0.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\AutoTest.TestRunners.Shared.dll"; DestDir: "{app}"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\NUnit\AutoTest.TestRunners.NUnit.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\NUnit\nunit.core.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\NUnit\nunit.core.interfaces.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\NUnit\nunit.util.dll"; DestDir: "{app}\TestRunners\NUnit"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\XUnit\AutoTest.TestRunners.XUnit.dll"; DestDir: "{app}\TestRunners\XUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\XUnit\xunit.runner.utility.dll"; DestDir: "{app}\TestRunners\XUnit"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\MSTest\AutoTest.TestRunners.MSTest.dll"; DestDir: "{app}\TestRunners\MSTest"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MSTest\celer.Core.dll"; DestDir: "{app}\TestRunners\MSTest"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\MSpec\AutoTest.TestRunners.MSpec.dll"; DestDir: "{app}\TestRunners\MSpec"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MSpec\Machine.Specifications.dll"; DestDir: "{app}\TestRunners\MSpec"; Flags: ignoreversion

Source: "..\ReleaseBinaries\TestRunners\MbUnit\AutoTest.TestRunners.MbUnit.dll"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MbUnit\Gallio.dll"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MbUnit\Gallio.XmlSerializers.dll"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion
Source: "..\ReleaseBinaries\TestRunners\MbUnit\mbunit.config"; DestDir: "{app}\TestRunners\MbUnit"; Flags: ignoreversion

Source: "..\ReleaseBinaries\Castle.Core.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Castle.Facilities.Logging.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Castle.license.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Castle.Windsor.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseBinaries\Mono.Cecil.dll"; DestDir: "{app}"; Flags: ignoreversion

Source: "..\src\AutoTest.Core\AutoTest.config.template.VS"; DestDir: "{app}"; Flags: ignoreversion

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:UninstallProgram,AutoTest.Net}"; Filename: "{uninstallexe}"

[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\10.0"; ValueType: string; ValueName: ""; ValueData: "AutomationOptions";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\10.0\AutomationOptions"; ValueType: string; ValueName: ""; ValueData: "LookInFolders";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\10.0\AutomationOptions\LookInFolders"; ValueType: string; ValueName: "{app}"; ValueData: ""; Flags: uninsdeletekey
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\9.0"; ValueType: string; ValueName: ""; ValueData: "AutomationOptions";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\9.0\AutomationOptions"; ValueType: string; ValueName: ""; ValueData: "LookInFolders";
Root: HKLM; Subkey: "SOFTWARE\Microsoft\VisualStudio\9.0\AutomationOptions\LookInFolders"; ValueType: string; ValueName: "{app}"; ValueData: ""; Flags: uninsdeletekey

[Run]
Filename:"{reg:HKLM\SOFTWARE\Microsoft\.NETFramework,InstallRoot}\{reg:HKCR\CLSID\{{61b3e12b-3586-3a58-a497-7ed7c4c794b9%7D\InprocServer32\2.0.0.0,RuntimeVersion}\RegAsm.exe"; Parameters: /codebase AutoTest.VSAddin.dll;WorkingDir: {app}; StatusMsg: "Registeringcontrols ..."; Flags: runhidden;

[UninstallRun]
Filename:"{app}\VSMenuKiller.exe"; Parameters: VisualStudio.DTE.10.0 MenuBar AutoTest.Net;WorkingDir: {app}; StatusMsg: "Removing 2010 addin ..."; Flags: runhidden;
Filename:"{app}\VSMenuKiller.exe"; Parameters: VisualStudio.DTE.9.0 MenuBar AutoTest.Net;WorkingDir: {app}; StatusMsg: "Removing 2008 addin ..."; Flags: runhidden;
Filename:"{reg:HKLM\SOFTWARE\Microsoft\.NETFramework,InstallRoot}\{reg:HKCR\CLSID\{{61b3e12b-3586-3a58-a497-7ed7c4c794b9%7D\InprocServer32\2.0.0.0,RuntimeVersion}\RegAsm.exe"; Parameters: /unregister AutoTest.VSAddin.dll; WorkingDir: {app}; StatusMsg: "Unregisteringcontrols ..."; Flags: runhidden;

[Code]


Add: Install VCRedist if missing when installing text overlay

copy-paste from browser overlay script

; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#include ReadReg(HKLM, 'Software\WOW6432Node\Mitrich Software\Inno Download Plugin', 'InstallDir') + '\idp.iss'

#define MyAppName "StreamCompanion - text ingame overlay plugin"
#define MyAppPublisher "Piotrekol"
#define MyAppURL "https://osustats.ppy.sh/"
#define AppId "{F6C83F00-59ED-493E-8310-181BB5B37A03}"

#define FilesRoot "..\build\Release_unsafe\"
#define ApplicationVersion GetFileVersion(FilesRoot +'Plugins\TextIngameOverlay.dll')
[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={{#AppId}
AppName={#MyAppName}
AppVersion={#ApplicationVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=license.txt
OutputBaseFilename=StreamCompanion-textOverlay
SetupIconFile=..\osu!StreamCompanion\Resources\compiled.ico
Compression=lzma
SolidCompression=yes
AppMutex=Global\{{2c6fc9bd-4e26-42d3-acfa-0a4d846d7e9e}

UsePreviousAppDir=yes
CreateUninstallRegKey=no
UpdateUninstallLogAppName=no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: {#FilesRoot}*; DestDir: "{app}"; Flags: ignoreversion recursesubdirs

[InstallDelete]
Type: files; Name: "{app}\Plugins\osuOverlayPlugin.dll"
[CustomMessages]
IDP_DownloadFailed=Download of VCRedist failed. VCRedist is required to run StreamCompanion browser overlay.
IDP_RetryCancel=Click 'Retry' to try downloading the files again, or click 'Cancel' to terminate setup.
InstallingVCRedist=Installing VCRedist. This might take a few minutes...
VCRedistFailedToLaunch=Failed to launch VCRedist Installer with error "%1". Please fix the error then run this installer again.
VCRedistFailedOther=The VCRedist installer exited with an unexpected status code "%1". Please review any other messages shown by the installer to determine whether the installation completed successfully, and abort this installation and fix the problem if it did not.

[Code]

function InitializeSetup(): Boolean;
begin
  Result := True;
  if not (
          RegKeyExists(HKEY_LOCAL_MACHINE,
           'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
          RegKeyExists(HKEY_CURRENT_USER,
           'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
          RegKeyExists(HKEY_CURRENT_USER,
           'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1')
          ) then
  begin
    MsgBox('StreamCompanion was not found - Aborting!', mbError, MB_OK);
    Result := False;
  end;
end;

function VCRedistIsMissing: Boolean;
var
  Version: String;
begin
  if RegQueryStringValue(HKEY_LOCAL_MACHINE,
       'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X86', 'Version', Version) then
  begin
    // Is the installed version at least 14.32 ?
    Log('VC Redist Version check : found ' + Version);
    Result := (CompareStr(Version, 'v14.32.31326.00')<0);
  end
  else
  begin
    // VCRedist not found
    Result := True;
  end;
end;

procedure InitializeWizard;
begin
  if VCRedistIsMissing() then
  begin
    idpAddFile('https://aka.ms/vs/17/release/vc_redist.x86.exe', ExpandConstant('{tmp}\vc_redist.x86.exe'));
    idpDownloadAfter(wpReady);
  end;
end;

function InstallVCRedist(): String;
var
  StatusText: string;
  ResultCode: Integer;
begin
  StatusText := WizardForm.StatusLabel.Caption;
  WizardForm.StatusLabel.Caption := CustomMessage('InstallingVCRedist');
  WizardForm.ProgressGauge.Style := npbstMarquee;
  try
    if not Exec(ExpandConstant('{tmp}\vc_redist.x86.exe'), '/passive /norestart /showrmui /showfinalerror', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      Result := FmtMessage(CustomMessage('VCRedistFailedToLaunch'), [SysErrorMessage(resultCode)]);
    end
    else
    begin
      case resultCode of
        0: begin
          // Successful
        end;
        else begin
          MsgBox(FmtMessage(CustomMessage('VCRedistFailedOther'), [IntToStr(resultCode)]), mbError, MB_OK);
        end;
      end;
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal;

    DeleteFile(ExpandConstant('{tmp}\vc_redist.x86.exe'));
  end;
end;

function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
  if VCRedistIsMissing() then
  begin
    Result := InstallVCRedist();
  end;
end;

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

#define MyAppName "StreamCompanion - text ingame overlay plugin"
#define MyAppPublisher "Piotrekol"
#define MyAppURL "https://osustats.ppy.sh/"
#define AppId "{F6C83F00-59ED-493E-8310-181BB5B37A03}"

#define FilesRoot "..\build\Release_unsafe\"
#define ApplicationVersion GetFileVersion(FilesRoot +'Plugins\TextIngameOverlay.dll')
[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={{#AppId}
AppName={#MyAppName}
AppVersion={#ApplicationVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=license.txt
OutputBaseFilename=StreamCompanion-textOverlay
SetupIconFile=..\osu!StreamCompanion\Resources\compiled.ico
Compression=lzma
SolidCompression=yes
AppMutex=Global\{{2c6fc9bd-4e26-42d3-acfa-0a4d846d7e9e}

UsePreviousAppDir=yes
CreateUninstallRegKey=no
UpdateUninstallLogAppName=no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: {#FilesRoot}*; DestDir: "{app}"; Flags: ignoreversion recursesubdirs

[InstallDelete]
Type: files; Name: "{app}\Plugins\osuOverlayPlugin.dll"

[Code]

function InitializeSetup(): Boolean;
begin
  Result := True;
  if not (
          RegKeyExists(HKEY_LOCAL_MACHINE,
           'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
          RegKeyExists(HKEY_CURRENT_USER,
           'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
          RegKeyExists(HKEY_CURRENT_USER,
           'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1')
          ) then
  begin
    MsgBox('StreamCompanion was not found - Aborting!', mbError, MB_OK);
    Result := False;
  end;
end;


update windows installer to use new qhy sdk dll

; PHD2 installer script
; Generated by Bret McKee on 2013/03/23
; Updated to install independently of PHD1 by Andy Galasso on 2013/7/25

#define APP_NAME "PHD 2"
#define APP_VERSION "2.5.0"

[Setup]
AppName={#APP_NAME}
AppVersion={#APP_VERSION}
DefaultDirName={pf}\PHDGuiding2
DefaultGroupName=PHD Guiding 2
UninstallDisplayIcon={app}\phd2.exe
Compression=lzma2
SolidCompression=yes
OutputDir=.
OutputBaseFilename=phd2-v{#APP_VERSION}-installer
DirExistsWarning=no

[Files]
Source: Release\phd2.exe; DestDir: {app}; Flags: replacesameversion
Source: locale\*; Excludes: *-old.*,help; DestDir: {app}\locale; Flags: recursesubdirs replacesameversion
Source: PHD2GuideHelp.zip; DestDir: {app}; Flags: replacesameversion
Source: README-PHD2.txt; DestDir: {app}; Flags: isreadme replacesameversion
Source: WinLibs\astroDLLGeneric.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\astroDLLQHY5V.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\astroDLLsspiag.dll; DestDir: {app}; Flags: replacesameversion
#emit 'Source: "' + GetEnv("CFITSIO") + '\cfitsio.dll";             DestDir: "{app}"; Flags: replacesameversion'
Source: WinLibs\CMOSDLL.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\DICAMSDK.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\DSCI.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\FcApi.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\inpout32.dll; DestDir: {app}; Flags: replacesameversion
#emit 'Source: "' + GetEnv("OPENCV_DIR") + '\x86\vc12\bin\opencv_core245.dll"; DestDir: "{app}"; Flags: replacesameversion'
#emit 'Source: "' + GetEnv("OPENCV_DIR") + '\x86\vc12\bin\opencv_highgui245.dll"; DestDir: "{app}"; Flags: replacesameversion'
#emit 'Source: "' + GetEnv("OPENCV_DIR") + '\x86\vc12\bin\opencv_imgproc245.dll"; DestDir: "{app}"; Flags: replacesameversion'
Source: WinLibs\qhyccd.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\ShoestringGPUSB_DLL.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\ShoestringLXUSB_DLL.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSAGIFv2.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSAGIFv4.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSPIAGCAM.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSPIAGUSB_WIN.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SXUSB.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\ASICamera2.dll; DestDir: {app}; Flags: replacesameversion
Source: Build\dark_mover.vbs; DestDir: {tmp}; Flags: replacesameversion
; Missing: TIS_DShowLib09.dll
; Missing: TIS_UDSHL09_vc10.dll
; Missing: TIS_UDSHL09_vc9.dll
Source: WinLibs\vcredist_x86.exe; DestDir: {tmp}; Flags: deleteafterinstall

[Icons]
Name: {group}\PHD Guiding 2; FileName: {app}\phd2.exe

[Run]
Filename: {tmp}\vcredist_x86.exe; Check: VCRedistNeedsInstall
Filename: {tmp}\dark_mover.vbs; Description: Relocate dark files; Flags: shellexec waituntilterminated
Filename: {app}\phd2.exe; Description: Launch {#APP_NAME} after installation; Flags: nowait postinstall skipifsilent

[Registry]
Root: HKCU; Subkey: Software\StarkLabs; Flags: uninsdeletekeyifempty
Root: HKCU; Subkey: Software\StarkLabs\PHDGuidingV2; Flags: uninsdeletekey

[Code]
#IFDEF UNICODE
  #DEFINE AW "W"
#ELSE
  #DEFINE AW "A"
#ENDIF
type
  INSTALLSTATE = Longint;
const
  INSTALLSTATE_INVALIDARG = -2;  // An invalid parameter was passed to the function.
  INSTALLSTATE_UNKNOWN = -1;     // The product is neither advertised or installed.
  INSTALLSTATE_ADVERTISED = 1;   // The product is advertised but not installed.
  INSTALLSTATE_ABSENT = 2;       // The product is installed for a different user.
  INSTALLSTATE_DEFAULT = 5;      // The product is installed for the current user.

  VC_2010_REDIST_X86 = '{196BB40D-1578-3D01-B289-BEFC77A11A1E}';
  VC_2010_SP1_REDIST_X86 = '{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}';
  VC_2013_REDIST_X86 = '{13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}';

function MsiQueryProductState(szProduct: string): INSTALLSTATE;
  external 'MsiQueryProductState{#AW}@msi.dll stdcall';

function VCVersionInstalled(const ProductID: string): Boolean;
begin
  Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT;
end;

function VCRedistNeedsInstall: Boolean;
begin
  Result := not (VCVersionInstalled(VC_2013_REDIST_X86));
end;

; PHD2 installer script
; Generated by Bret McKee on 2013/03/23
; Updated to install independently of PHD1 by Andy Galasso on 2013/7/25

#define APP_NAME "PHD 2"
#define APP_VERSION "2.5.0"

[Setup]
AppName={#APP_NAME}
AppVersion={#APP_VERSION}
DefaultDirName={pf}\PHDGuiding2
DefaultGroupName=PHD Guiding 2
UninstallDisplayIcon={app}\phd2.exe
Compression=lzma2
SolidCompression=yes
OutputDir=.
OutputBaseFilename=phd2-v{#APP_VERSION}-installer
DirExistsWarning=no

[Files]
Source: Release\phd2.exe; DestDir: {app}; Flags: replacesameversion
Source: locale\*; Excludes: *-old.*,help; DestDir: {app}\locale; Flags: recursesubdirs replacesameversion
Source: PHD2GuideHelp.zip; DestDir: {app}; Flags: replacesameversion
Source: README-PHD2.txt; DestDir: {app}; Flags: isreadme replacesameversion
Source: WinLibs\astroDLLGeneric.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\astroDLLQHY5V.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\astroDLLsspiag.dll; DestDir: {app}; Flags: replacesameversion
#emit 'Source: "' + GetEnv("CFITSIO") + '\cfitsio.dll";             DestDir: "{app}"; Flags: replacesameversion'
Source: WinLibs\CMOSDLL.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\DICAMSDK.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\DSCI.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\FcApi.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\inpout32.dll; DestDir: {app}; Flags: replacesameversion
#emit 'Source: "' + GetEnv("OPENCV_DIR") + '\x86\vc12\bin\opencv_core245.dll"; DestDir: "{app}"; Flags: replacesameversion'
#emit 'Source: "' + GetEnv("OPENCV_DIR") + '\x86\vc12\bin\opencv_highgui245.dll"; DestDir: "{app}"; Flags: replacesameversion'
#emit 'Source: "' + GetEnv("OPENCV_DIR") + '\x86\vc12\bin\opencv_imgproc245.dll"; DestDir: "{app}"; Flags: replacesameversion'
Source: WinLibs\qhy5IIdll.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\qhy5LIIdll.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\ShoestringGPUSB_DLL.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\ShoestringLXUSB_DLL.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSAGIFv2.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSAGIFv4.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSPIAGCAM.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SSPIAGUSB_WIN.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\SXUSB.dll; DestDir: {app}; Flags: replacesameversion
Source: WinLibs\ASICamera2.dll; DestDir: {app}; Flags: replacesameversion
Source: Build\dark_mover.vbs; DestDir: {tmp}; Flags: replacesameversion
; Missing: TIS_DShowLib09.dll
; Missing: TIS_UDSHL09_vc10.dll
; Missing: TIS_UDSHL09_vc9.dll
Source: WinLibs\vcredist_x86.exe; DestDir: {tmp}; Flags: deleteafterinstall

[Icons]
Name: {group}\PHD Guiding 2; FileName: {app}\phd2.exe

[Run]
Filename: {tmp}\vcredist_x86.exe; Check: VCRedistNeedsInstall
Filename: {tmp}\dark_mover.vbs; Description: Relocate dark files; Flags: shellexec waituntilterminated
Filename: {app}\phd2.exe; Description: Launch {#APP_NAME} after installation; Flags: nowait postinstall skipifsilent

[Registry]
Root: HKCU; Subkey: Software\StarkLabs; Flags: uninsdeletekeyifempty
Root: HKCU; Subkey: Software\StarkLabs\PHDGuidingV2; Flags: uninsdeletekey

[Code]
#IFDEF UNICODE
  #DEFINE AW "W"
#ELSE
  #DEFINE AW "A"
#ENDIF
type
  INSTALLSTATE = Longint;
const
  INSTALLSTATE_INVALIDARG = -2;  // An invalid parameter was passed to the function.
  INSTALLSTATE_UNKNOWN = -1;     // The product is neither advertised or installed.
  INSTALLSTATE_ADVERTISED = 1;   // The product is advertised but not installed.
  INSTALLSTATE_ABSENT = 2;       // The product is installed for a different user.
  INSTALLSTATE_DEFAULT = 5;      // The product is installed for the current user.

  VC_2010_REDIST_X86 = '{196BB40D-1578-3D01-B289-BEFC77A11A1E}';
  VC_2010_SP1_REDIST_X86 = '{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}';
  VC_2013_REDIST_X86 = '{13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}';

function MsiQueryProductState(szProduct: string): INSTALLSTATE;
  external 'MsiQueryProductState{#AW}@msi.dll stdcall';

function VCVersionInstalled(const ProductID: string): Boolean;
begin
  Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT;
end;

function VCRedistNeedsInstall: Boolean;
begin
  Result := not (VCVersionInstalled(VC_2013_REDIST_X86));
end;