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

View file

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