duniter.iss 3.62 KB
Newer Older
Cédric Moreau's avatar
Cédric Moreau committed
1
2
3
4
5
6
7
8
9
10
#define MyAppName "Duniter"
#define MyAppPublisher "Duniter team"
#define MyAppURL "http://duniter.org"
#define MyAppExeName "nw.exe"

#if !Defined(ROOT_PATH)
#define ROOT_PATH "."
#endif

#define MyAppSrc ROOT_PATH
Cédric Moreau's avatar
Cédric Moreau committed
11
#define MyAppExe ROOT_PATH + "\" + MyAppExeName
Cédric Moreau's avatar
Cédric Moreau committed
12
13
14
15
16
17
#pragma message MyAppSrc

#if !FileExists(MyAppExe)
#error "Unable to find MyAppExe"
#endif

Cédric Moreau's avatar
v1.5.0    
Cédric Moreau committed
18
#define MyAppVerStr "v1.5.0"
Cédric Moreau's avatar
Cédric Moreau committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVerStr}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir={#ROOT_PATH}
OutputBaseFilename={#MyAppName}
Compression=lzma
SolidCompression=yes
Cédric Moreau's avatar
Cédric Moreau committed
35
UninstallDisplayIcon={app}\{#MyAppExeName}
36
ArchitecturesInstallIn64BitMode=x64
Cédric Moreau's avatar
Cédric Moreau committed
37
38
39
40
41
42
43
44
45

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

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Cédric Moreau's avatar
Cédric Moreau committed
46
Source: "{#MyAppSrc}\*"; DestDir: "{app}\"; Flags: ignoreversion recursesubdirs
Cédric Moreau's avatar
Cédric Moreau committed
47
48

[Icons]
Cédric Moreau's avatar
Cédric Moreau committed
49
Name: "{group}\{#MyAppName}"; IconFilename: "{app}\duniter.ico"; Filename: "{app}\{#MyAppExeName}"
Cédric Moreau's avatar
Cédric Moreau committed
50
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Cédric Moreau's avatar
Cédric Moreau committed
51
Name: "{commondesktop}\{#MyAppName}"; IconFilename: "{app}\duniter.ico"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Cédric Moreau's avatar
Cédric Moreau committed
52
53

[Run]
Cédric Moreau's avatar
Cédric Moreau committed
54
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
Cédric Moreau's avatar
Cédric Moreau committed
55
56
57
58
59
60

[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={{E01B0960-74D2-8ACD-734E-8B3CB033B07F}
Cédric Moreau's avatar
Cédric Moreau committed
61
LicenseFile="{#MyAppSrc}\LICENSE"
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

[Code]

//////////
// Code taken from http://stackoverflow.com/a/2099805
//////////

/////////////////////////////////////////////////////////////////////
function GetUninstallString(): String;
var
  sUnInstPath: String;
  sUnInstallString: String;
begin
  sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
  sUnInstallString := '';
  if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
    RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
  Result := sUnInstallString;
end;


/////////////////////////////////////////////////////////////////////
function IsUpgrade(): Boolean;
begin
  Result := (GetUninstallString() <> '');
end;


/////////////////////////////////////////////////////////////////////
function UnInstallOldVersion(): Integer;
var
  sUnInstallString: String;
  iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString

  // default return value
  Result := 0;

  // get the uninstall string of the old app
  sUnInstallString := GetUninstallString();
  if sUnInstallString <> '' then begin
    sUnInstallString := RemoveQuotes(sUnInstallString);
    if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
      Result := 3
    else
      Result := 2;
  end else
    Result := 1;
end;

/////////////////////////////////////////////////////////////////////
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if (CurStep=ssInstall) then
  begin
    if (IsUpgrade()) then
    begin
      UnInstallOldVersion();
    end;
  end;
end;