ReactOS 0.4.15-dev-7788-g1ad9096
registry.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Utility Manager Resources DLL (UManDlg.dll)
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Registry functions for Utility Manager settings management
5 * COPYRIGHT: Copyright 2020 George Bișoc (george.bisoc@reactos.org)
6 */
7
8/* INCLUDES *******************************************************************/
9
10#include "umandlg.h"
11
12/* GLOBALS ********************************************************************/
13
16
17/* DEFINES ********************************************************************/
18
19#define ACCESS_UTILMAN_KEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Accessibility\\Utility Manager"
20#define UTILMAN_KEY L"SOFTWARE\\Microsoft\\Utility Manager"
21#define OSK_KEY L"On-Screen Keyboard"
22#define MAGNIFIER_KEY L"Magnifier"
23
24/* FUNCTIONS ******************************************************************/
25
50BOOL InitAppRegKey(IN HKEY hPredefinedKey,
51 IN LPCWSTR lpszSubKey,
52 OUT PHKEY phKey,
53 OUT LPDWORD lpdwDisposition)
54{
55 LONG lResult;
56
57 lResult = RegCreateKeyExW(hPredefinedKey,
58 lpszSubKey,
59 0,
60 NULL,
61 0,
63 NULL,
64 phKey,
65 lpdwDisposition);
66 if (lResult != ERROR_SUCCESS)
67 {
68 DPRINT("InitAppRegKey(): Failed to create the following key (or open the key) of path \"%S\". The error code is \"%li\".\n", lpszSubKey, lResult);
69 return FALSE;
70 }
71
72 return TRUE;
73}
74
103 IN LPCWSTR lpszSubKey,
104 IN LPCWSTR lpszRegValue,
105 OUT PVOID ReturnedData,
106 IN OUT LPDWORD lpdwSizeData)
107{
108 LONG lResult;
109 HKEY hKeyQueryValue;
110
111 lResult = RegOpenKeyExW(hKey,
112 lpszSubKey,
113 0,
114 KEY_READ,
115 &hKeyQueryValue);
116 if (lResult != ERROR_SUCCESS)
117 {
118 DPRINT("QueryAppSettings(): Failed to open the key of path \"%S\". The error code is \"%li\".\n", lpszSubKey, lResult);
119 return FALSE;
120 }
121
122 lResult = RegQueryValueExW(hKeyQueryValue,
123 lpszRegValue,
124 NULL,
125 NULL,
126 (LPBYTE)&ReturnedData,
127 lpdwSizeData);
128 if (lResult != ERROR_SUCCESS)
129 {
130 DPRINT("QueryAppSettings(): Failed to query the data from value \"%S\". The error code is \"%li\".\n", lpszRegValue, lResult);
131 RegCloseKey(hKeyQueryValue);
132 return FALSE;
133 }
134
135 RegCloseKey(hKeyQueryValue);
136 return TRUE;
137}
138
167 IN LPCWSTR lpszRegValue,
168 IN DWORD dwRegType,
169 IN PVOID Data,
170 IN DWORD cbSize)
171{
172 LONG lResult;
173 HKEY hKeySetValue;
174
175 lResult = RegOpenKeyExW(hKey,
176 NULL,
177 0,
179 &hKeySetValue);
180 if (lResult != ERROR_SUCCESS)
181 {
182 DPRINT("SaveAppSettings(): Failed to open the key, the error code is \"%li\"!\n", lResult);
183 return FALSE;
184 }
185
186 lResult = RegSetValueExW(hKeySetValue,
187 lpszRegValue,
188 0,
189 dwRegType,
190 (LPBYTE)&Data,
191 cbSize);
192 if (lResult != ERROR_SUCCESS)
193 {
194 DPRINT("SaveAppSettings(): Failed to set the \"%S\" value with data, the error code is \"%li\"!\n", lpszRegValue, lResult);
195 RegCloseKey(hKeySetValue);
196 return FALSE;
197 }
198
199 RegCloseKey(hKeySetValue);
200 return TRUE;
201}
BOOL InitAppRegKey(IN HKEY hPredefinedKey, IN LPCWSTR lpszSubKey, OUT PHKEY phKey, OUT LPDWORD lpdwDisposition)
Definition: registry.c:50
REGISTRY_SETTINGS Settings
Definition: registry.c:15
BOOL SaveAppSettings(IN HKEY hKey, IN LPCWSTR lpszRegValue, IN DWORD dwRegType, IN PVOID Data, IN DWORD cbSize)
Definition: registry.c:166
REGISTRY_DATA RegData
Definition: registry.c:14
BOOL QueryAppSettings(IN HKEY hKey, IN LPCWSTR lpszSubKey, IN LPCWSTR lpszRegValue, OUT PVOID ReturnedData, IN OUT LPDWORD lpdwSizeData)
Definition: registry.c:102
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4911
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4132
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define KEY_SET_VALUE
Definition: nt_native.h:1017
long LONG
Definition: pedump.c:60
#define DPRINT
Definition: sndvol32.h:71
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t * LPDWORD
Definition: typedefs.h:59
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185