-
Notifications
You must be signed in to change notification settings - Fork 1
/
SetupScriptRelease.iss
109 lines (97 loc) · 3.76 KB
/
SetupScriptRelease.iss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define Dir "..\TextEditor\TextEditor\bin\Release"
#define Path "..\TextEditor\TextEditor\bin\Release\TextEditor.exe"
#define Name GetStringFileInfo(Path, "ProductName")
#define Publisher GetStringFileInfo(Path, "CompanyName")
#define ExeName Name + ".exe"
#define AppVersion GetFileVersion(Path)
#define GUID "674DC930-9FA6-42BE-9602-C4653197B721"
[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={#GUID}
AppName={#Name}
AppVersion={#AppVersion}
AppVerName={#Name} {#AppVersion}
AppPublisher={#Publisher}
DefaultDirName={pf}\{#Name}
DefaultGroupName={#Name}
AllowNoIcons=yes
OutputDir=..\TextEditor\TextEditor\bin\
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: {#Path}; DestDir: "{app}"; Flags: ignoreversion
Source: "{#Dir}\Resources\exit_icon.png"; DestDir: "{app}\Resources"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#Name}"; Filename: "{app}\{#ExeName}"
Name: "{group}\{cm:UninstallProgram,{#Name}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#Name}"; Filename: "{app}\{#ExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#ExeName}"; Description: "{cm:LaunchProgram,{#StringChange(Name, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
function isDotNetDetected(): Boolean;
var
reg_key: string;
key_value: cardinal;
sub_key: string;
success: boolean;
begin
reg_key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\';
sub_key := 'v4\Full';
reg_key := reg_key + sub_key;
success := RegQueryDWordValue(HKLM, reg_key, 'Install', key_value);
success := success and (key_value = 1);
result := success;
end;
function GetUninstallString: string;
var
sUnInstPath: string;
sUnInstallString: String;
begin
Result := '';
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#GUID}_is1'); //Your App GUID/ID
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 InitializeSetup(): boolean;
var
V: Integer;
iResultCode: Integer;
sUnInstallString: string;
begin
Result := True; // in case when no previous version is found
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#GUID}_is1', 'UninstallString') then //Your App GUID/ID
begin
V := MsgBox(ExpandConstant('Hey! An old version of app was detected. Do you want to uninstall it?'), mbInformation, MB_YESNO); //Custom Message if App installed
if V = IDYES then
begin
sUnInstallString := GetUninstallString();
sUnInstallString := RemoveQuotes(sUnInstallString);
Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
Result := True;
end
else
Result := False; //when older version present and not uninstalled
end;
if not isDotNetDetected() then
begin
MsgBox('{#Name} requires Microsoft .NET Framework 4.0 Full Profile.'#13#13
'You can download it here: http://www.microsoft.com/en-us/download/details.aspx?id=17851', mbInformation, MB_OK);
end;
result := true;
end;