templates/windows/installer: Opt for built-in Registry functions

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2022-09-19 23:50:38 +02:00
parent 53ceddd784
commit 79e736bc75
1 changed files with 4 additions and 31 deletions

View File

@ -101,40 +101,13 @@ type
WPARAM = UINT_PTR; WPARAM = UINT_PTR;
LPARAM = INT_PTR; LPARAM = INT_PTR;
LRESULT = INT_PTR; LRESULT = INT_PTR;
LSTATUS = DWord;
LPCVOID = UINT_PTR;
HKEY = DWord;
PHKEY = UINT_PTR;
const const
SMTO_ABORTIFHUNG = 2; SMTO_ABORTIFHUNG = 2;
WM_WININICHANGE = $001A; WM_WININICHANGE = $001A;
WM_SETTINGCHANGE = WM_WININICHANGE; WM_SETTINGCHANGE = WM_WININICHANGE;
// HKEY_CURRENT_USER = $80000001;
// HKEY_LOCAL_MACHINE = $80000002;
function advapi32_RegSetKeyValue( function user32_SendTextMessageTimeoutA(
hKey: HKEY;
lpSubKey: string;
lpValueName: string;
dwType: DWord;
lpData: string;
dwData: DWord
): LRESULT;
external 'RegSetKeyValue{#AW}@advapi32.dll stdcall';
function SetRegistryKeyValueString(
Root: HKEY;
Key: string;
Name: string;
Value: string
): BOOL;
begin
advapi32_RegSetKeyValue(Root, Key, Name, 2, Value, Length(Value) * 2);
Result := True;
end;
function user32_SendTextMessageTimeout(
hWnd: HWND; hWnd: HWND;
Msg: UINT; Msg: UINT;
wParam: WPARAM; wParam: WPARAM;
@ -150,7 +123,7 @@ var
MsgResult: DWORD; MsgResult: DWORD;
begin begin
S := 'Environment'; S := 'Environment';
user32_SendTextMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, user32_SendTextMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
PAnsiChar(S), SMTO_ABORTIFHUNG, 5000, MsgResult); PAnsiChar(S), SMTO_ABORTIFHUNG, 5000, MsgResult);
end; end;
@ -272,11 +245,11 @@ begin
if (IsUserMode()) then begin if (IsUserMode()) then begin
sPluginsPath := ExpandConstant('{userpf}\obs-studio\plugins\%module%\bin\'); sPluginsPath := ExpandConstant('{userpf}\obs-studio\plugins\%module%\bin\');
StringChangeEx(sPluginsPath, '\', '/', True); StringChangeEx(sPluginsPath, '\', '/', True);
SetRegistryKeyValueString(HKEY_CURRENT_USER, 'Environment', 'OBS_PLUGINS_PATH', sPluginsPath); RegWriteExpandStringValue(HKEY_CURRENT_USER, 'Environment', 'OBS_PLUGINS_PATH', sPluginsPath);
sPluginsDataPath := ExpandConstant('{userpf}\obs-studio\plugins\%module%\data\'); sPluginsDataPath := ExpandConstant('{userpf}\obs-studio\plugins\%module%\data\');
StringChangeEx(sPluginsDataPath, '\', '/', True); StringChangeEx(sPluginsDataPath, '\', '/', True);
SetRegistryKeyValueString(HKEY_CURRENT_USER, 'Environment', 'OBS_PLUGINS_DATA_PATH', sPluginsDataPath); RegWriteExpandStringValue(HKEY_CURRENT_USER, 'Environment', 'OBS_PLUGINS_DATA_PATH', sPluginsDataPath);
RefreshEnvironment(); RefreshEnvironment();
end; end;