1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-08 11:34:05 +02:00

Refactor installation files (move .NET Framework check to a function)

This commit is contained in:
chylex 2016-10-09 00:53:59 +02:00
parent 82beb1f5a7
commit 7e3014c52d
2 changed files with 52 additions and 41 deletions

View File

@ -56,22 +56,12 @@ Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache"
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache"
[Code]
function InitializeSetup: Boolean;
var FrameworkVersion: Cardinal;
var HasCorrectVersion: Boolean;
function TDGetNetFrameworkVersion: Cardinal; forward;
{ Check .NET Framework version on startup, ask user if they want to proceed if older than 4.5.1. }
function InitializeSetup: Boolean;
begin
HasCorrectVersion := False;
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', FrameworkVersion) then
begin
if FrameworkVersion >= 379893 then
begin
HasCorrectVersion := True;
end;
end;
if HasCorrectVersion then
if TDGetNetFrameworkVersion() >= 379893 then
begin
Result := True;
Exit;
@ -86,6 +76,7 @@ begin
Result := True;
end;
{ Ask user if they want to delete 'AppData\TweetDuck' and 'plugins' folders after uninstallation. }
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var ProfileDataFolder: String;
var PluginDataFolder: String;
@ -103,4 +94,18 @@ begin
DelTree(ExpandConstant('{app}'), True, False, False);
end;
end;
end;
end;
{ Return DWORD value containing the build version of .NET Framework. }
function TDGetNetFrameworkVersion: Cardinal;
var FrameworkVersion: Cardinal;
begin
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', FrameworkVersion) then
begin
Result := FrameworkVersion;
Exit;
end;
Result := 0;
end;

View File

@ -59,22 +59,12 @@ Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache"
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache"
[Code]
function InitializeSetup: Boolean;
var FrameworkVersion: Cardinal;
var HasCorrectVersion: Boolean;
function TDGetNetFrameworkVersion: Cardinal; forward;
{ Check .NET Framework version on startup, ask user if they want to proceed if older than 4.5.1. }
function InitializeSetup: Boolean;
begin
HasCorrectVersion := False;
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', FrameworkVersion) then
begin
if FrameworkVersion >= 379893 then
begin
HasCorrectVersion := True;
end;
end;
if HasCorrectVersion then
if TDGetNetFrameworkVersion() >= 379893 then
begin
Result := True;
Exit;
@ -89,15 +79,7 @@ begin
Result := True;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
DeleteFile(ExpandConstant('{app}\unins000.dat'))
DeleteFile(ExpandConstant('{app}\unins000.exe'))
end;
end;
{ Ask user if they want to delete 'AppData\TweetDuck' and 'plugins' folders after uninstallation. }
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var ProfileDataFolder: String;
var PluginDataFolder: String;
@ -105,8 +87,8 @@ var PluginDataFolder: String;
begin
if CurUninstallStep = usPostUninstall then
begin
ProfileDataFolder := ExpandConstant('{localappdata}\{#MyAppName}')
PluginDataFolder := ExpandConstant('{app}\plugins')
ProfileDataFolder := ExpandConstant('{localappdata}\{#MyAppName}');
PluginDataFolder := ExpandConstant('{app}\plugins');
if (DirExists(ProfileDataFolder) or DirExists(PluginDataFolder)) and (MsgBox('Do you also want to delete your {#MyAppName} profile and plugins?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES) then
begin
@ -115,4 +97,28 @@ begin
DelTree(ExpandConstant('{app}'), True, False, False);
end;
end;
end;
end;
{ Remove uninstallation data and application to force them to be replaced with updated ones. }
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
DeleteFile(ExpandConstant('{app}\unins000.dat'));
DeleteFile(ExpandConstant('{app}\unins000.exe'));
end;
end;
{ Return DWORD value containing the build version of .NET Framework. }
function TDGetNetFrameworkVersion: Cardinal;
var FrameworkVersion: Cardinal;
begin
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', FrameworkVersion) then
begin
Result := FrameworkVersion;
Exit;
end;
Result := 0;
end;