templates/windows/installer: Install System-wide installations to ProgramData

With OBS Studio 0.15.0 came a better location for plugins to install to, which solves many of the current issues. While this location still requires Administrator rights to write to, it is a much safer location than writing directly into the OBS Studio installation directory.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2022-09-17 10:06:02 +02:00
parent 12c9fe51fb
commit 3ce695bccc
1 changed files with 30 additions and 24 deletions

View File

@ -60,7 +60,7 @@ AppendDefaultGroupName=yes
; Other Information
Uninstallable=yes
CreateUninstallRegKey=not IsPortablePagePortableChoiceChecked()
CreateUninstallRegKey=not IsPortableMode()
AllowNoIcons=yes
LicenseFile="@ISS_SOURCE_DIR@/LICENSE"
OutputDir="@ISS_PACKAGE_DIR@"
@ -97,10 +97,10 @@ function GetOutputBinaryDir(Value: String): String; forward;
function GetOutputDataDir(Value: String): String; forward;
// Which installation mode is selected?
function IsPortablePagePortableChoiceChecked(): Boolean; forward;
function IsPortableMode(): Boolean; forward;
// Other Metadata
function FindRegistryKey(): String; forward;
function AppRegistryKey(): String; forward;
function GetUninstallerPath(): String; forward;
function IsUpgrade(): Boolean; forward;
function UninstallOldVersion(): Integer; forward;
@ -146,16 +146,13 @@ var
sPath: String;
begin
// Otherwise, try and figure out where the previous installation of the same type went to.
if (RegQueryStringValue(HKA64, FindRegistryKey(), 'InstallLocation', sPath)) then begin
if (RegQueryStringValue(HKA64, AppRegistryKey(), 'InstallLocation', sPath)) then begin
Result := sPath;
exit;
end;
// Install to OBS Studio by default.
if (RegQueryStringValue(HKLM64, 'SOFTWARE\OBS Studio', '', sPath)) then begin
Result := sPath;
exit;
end;
// Install to ProgramData.
Result := ExpandConstant('{commonappdata}\obs-studio\plugins\@PROJECT_NAME@');
exit;
end;
@ -165,7 +162,11 @@ function GetOutputBinaryDir(Value: String): String;
var
sPath: String;
begin
sPath := ExpandConstant('{app}\obs-plugins\@D_PLATFORM_BITS@bit\');
if (IsPortableMode()) then begin
sPath := ExpandConstant('{app}\obs-plugins\@D_PLATFORM_BITS@bit\');
end else begin
sPath := ExpandConstant('{app}\bin\@D_PLATFORM_BITS@bit\');
end;
Result := sPath;
end;
@ -173,23 +174,21 @@ function GetOutputDataDir(Value: String): String;
var
sPath: String;
begin
sPath := ExpandConstant('{app}\data\obs-plugins\@PROJECT_NAME@\');
if (IsPortableMode()) then begin
sPath := ExpandConstant('{app}\data\obs-plugins\@PROJECT_NAME@\');
end else begin
sPath := ExpandConstant('{app}\data\');
end;
Result := sPath;
end;
// ------------------------------------------------------------------------------------------------------------------ //
function FindRegistryKey(): String;
begin
Result := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting('AppId')}_is1');
end;
// ------------------------------------------------------------------------------------------------------------------ //
function GetUninstallerPath(): String;
var
sRegistryKey: String;
sUninstallerPath: String;
begin
sRegistryKey := FindRegistryKey();
sRegistryKey := AppRegistryKey();
RegQueryStringValue(HKLM64, sRegistryKey, 'UninstallString', sUninstallerPath);
@ -205,10 +204,22 @@ begin
Result := sUninstallerPath;
end;
// ------------------------------------------------------------------------------------------------------------------ //
function IsPortableMode(): Boolean;
begin
Result := oPortablePagePortableChoice.Checked;
end;
// ------------------------------------------------------------------------------------------------------------------ //
function AppRegistryKey(): String;
begin
Result := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting('AppId')}_is1');
end;
// ------------------------------------------------------------------------------------------------------------------ //
function IsUpgrade(): Boolean;
begin
Result := (not IsPortablePagePortableChoiceChecked()) and (GetUninstallerPath() <> '');
Result := (not IsPortableMode()) and (GetUninstallerPath() <> '');
end;
// ------------------------------------------------------------------------------------------------------------------ //
@ -246,11 +257,6 @@ begin
end;
end;
function IsPortablePagePortableChoiceChecked(): Boolean;
begin
Result := oPortablePagePortableChoice.Checked;
end;
function CreatePortablePage: TWizardPage;
var
oPage: TWizardPage;