ReactOS  0.4.14-dev-49-gfb4591c
settings.c File Reference
#include "precomp.h"
Include dependency graph for settings.c:

Go to the source code of this file.

Functions

BOOL LoadDataFromRegistry (VOID)
 
BOOL SaveDataToRegistry (VOID)
 

Function Documentation

◆ LoadDataFromRegistry()

BOOL LoadDataFromRegistry ( VOID  )

Definition at line 14 of file settings.c.

15 {
16  HKEY hKey;
17  LONG lResult;
18  DWORD dwValue;
19  DWORD cbData = sizeof(DWORD);
20 
21  /* Initialize the registry application settings */
22  Globals.bShowWarning = TRUE;
23  Globals.bIsEnhancedKeyboard = TRUE;
24  Globals.bSoundClick = FALSE;
25  Globals.bAlwaysOnTop = TRUE;
26 
27  /* Set the coordinate values to default */
28  Globals.PosX = CW_USEDEFAULT;
29  Globals.PosY = CW_USEDEFAULT;
30 
31  /* Open the key, so that we can query it */
33  L"Software\\Microsoft\\Osk",
34  0,
35  KEY_READ,
36  &hKey);
37 
38  if (lResult != ERROR_SUCCESS)
39  {
40  /* Bail out and return FALSE if we fail */
41  return FALSE;
42  }
43 
44  /* Query the key */
45  lResult = RegQueryValueExW(hKey,
46  L"ShowWarning",
47  0,
48  0,
49  (BYTE *)&dwValue,
50  &cbData);
51 
52  if (lResult != ERROR_SUCCESS)
53  {
54  /* Bail out and return FALSE if we fail */
55  RegCloseKey(hKey);
56  return FALSE;
57  }
58 
59  /* Load the data value (it can be either FALSE or TRUE depending on the data itself) */
60  Globals.bShowWarning = (dwValue != 0);
61 
62  /* Query the key */
63  lResult = RegQueryValueExW(hKey,
64  L"IsEnhancedKeyboard",
65  0,
66  0,
67  (BYTE *)&dwValue,
68  &cbData);
69 
70  if (lResult != ERROR_SUCCESS)
71  {
72  /* Bail out and return FALSE if we fail */
73  RegCloseKey(hKey);
74  return FALSE;
75  }
76 
77  /* Load the dialog layout value */
78  Globals.bIsEnhancedKeyboard = (dwValue != 0);
79 
80  /* Query the key */
81  lResult = RegQueryValueExW(hKey,
82  L"ClickSound",
83  0,
84  0,
85  (BYTE *)&dwValue,
86  &cbData);
87 
88  if (lResult != ERROR_SUCCESS)
89  {
90  /* Bail out and return FALSE if we fail */
91  RegCloseKey(hKey);
92  return FALSE;
93  }
94 
95  /* Load the sound on click value event */
96  Globals.bSoundClick = (dwValue != 0);
97 
98  /* Query the key */
99  lResult = RegQueryValueExW(hKey,
100  L"WindowLeft",
101  0,
102  0,
103  (BYTE *)&dwValue,
104  &cbData);
105 
106  if (lResult != ERROR_SUCCESS)
107  {
108  /* Bail out and return FALSE if we fail */
109  RegCloseKey(hKey);
110  return FALSE;
111  }
112 
113  /* Load the X value data of the dialog's coordinate */
114  Globals.PosX = dwValue;
115 
116  lResult = RegQueryValueExW(hKey,
117  L"WindowTop",
118  0,
119  0,
120  (BYTE *)&dwValue,
121  &cbData);
122 
123  if (lResult != ERROR_SUCCESS)
124  {
125  /* Bail out and return FALSE if we fail */
126  RegCloseKey(hKey);
127  return FALSE;
128  }
129 
130  /* Load the Y value data of the dialog's coordinate */
131  Globals.PosY = dwValue;
132 
133  lResult = RegQueryValueExW(hKey,
134  L"AlwaysOnTop",
135  0,
136  0,
137  (BYTE *)&dwValue,
138  &cbData);
139 
140  if (lResult != ERROR_SUCCESS)
141  {
142  /* Bail out and return FALSE if we fail */
143  RegCloseKey(hKey);
144  return FALSE;
145  }
146 
147  /* Load the window state value data */
148  Globals.bAlwaysOnTop = (dwValue != 0);
149 
150  /* If we're here then we succeed, close the key and return TRUE */
151  RegCloseKey(hKey);
152  return TRUE;
153 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define DWORD
Definition: nt_native.h:44
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define CW_USEDEFAULT
Definition: winuser.h:225
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366

Referenced by OSK_RestoreDlgPlacement(), and wWinMain().

◆ SaveDataToRegistry()

BOOL SaveDataToRegistry ( VOID  )

Definition at line 155 of file settings.c.

156 {
157  HKEY hKey;
158  LONG lResult;
159  DWORD dwValue;
160  WINDOWPLACEMENT wp;
161 
162  /* Set the structure length and retrieve the dialog's placement */
163  wp.length = sizeof(WINDOWPLACEMENT);
165 
166  /* If no key has been made, create one */
168  L"Software\\Microsoft\\Osk",
169  0,
170  NULL,
171  0,
172  KEY_WRITE,
173  NULL,
174  &hKey,
175  NULL);
176 
177  if (lResult != ERROR_SUCCESS)
178  {
179  /* Bail out and return FALSE if we fail */
180  return FALSE;
181  }
182 
183  /* The data value of the subkey will be appended to the warning dialog switch */
184  dwValue = Globals.bShowWarning;
185 
186  /* Welcome warning box value key */
187  lResult = RegSetValueExW(hKey,
188  L"ShowWarning",
189  0,
190  REG_DWORD,
191  (BYTE *)&dwValue,
192  sizeof(dwValue));
193 
194  if (lResult != ERROR_SUCCESS)
195  {
196  /* Bail out and return FALSE if we fail */
197  RegCloseKey(hKey);
198  return FALSE;
199  }
200 
201  /* The value will be appended to the layout dialog */
202  dwValue = Globals.bIsEnhancedKeyboard;
203 
204  /* Keyboard dialog switcher */
205  lResult = RegSetValueExW(hKey,
206  L"IsEnhancedKeyboard",
207  0,
208  REG_DWORD,
209  (BYTE *)&dwValue,
210  sizeof(dwValue));
211 
212  if (lResult != ERROR_SUCCESS)
213  {
214  /* Bail out and return FALSE if we fail */
215  RegCloseKey(hKey);
216  return FALSE;
217  }
218 
219  /* The value will be appended to the sound on click event */
220  dwValue = Globals.bSoundClick;
221 
222  /* "Sound on Click" switcher value key */
223  lResult = RegSetValueExW(hKey,
224  L"ClickSound",
225  0,
226  REG_DWORD,
227  (BYTE *)&dwValue,
228  sizeof(dwValue));
229 
230  if (lResult != ERROR_SUCCESS)
231  {
232  /* Bail out and return FALSE if we fail */
233  RegCloseKey(hKey);
234  return FALSE;
235  }
236 
237  /* The value will be appended to the X coordination dialog's placement */
238  dwValue = wp.rcNormalPosition.left;
239 
240  /* Position X coordination of dialog's placement value key */
241  lResult = RegSetValueExW(hKey,
242  L"WindowLeft",
243  0,
244  REG_DWORD,
245  (BYTE *)&dwValue,
246  sizeof(dwValue));
247 
248  if (lResult != ERROR_SUCCESS)
249  {
250  /* Bail out and return FALSE if we fail */
251  RegCloseKey(hKey);
252  return FALSE;
253  }
254 
255  /* The value will be appended to the Y coordination dialog's placement */
256  dwValue = wp.rcNormalPosition.top;
257 
258  /* Position Y coordination of dialog's placement value key */
259  lResult = RegSetValueExW(hKey,
260  L"WindowTop",
261  0,
262  REG_DWORD,
263  (BYTE *)&dwValue,
264  sizeof(dwValue));
265 
266  if (lResult != ERROR_SUCCESS)
267  {
268  /* Bail out and return FALSE if we fail */
269  RegCloseKey(hKey);
270  return FALSE;
271  }
272 
273  /* Window top state value */
274  dwValue = Globals.bAlwaysOnTop;
275 
276  /* "Always on Top" state value key */
277  lResult = RegSetValueExW(hKey,
278  L"AlwaysOnTop",
279  0,
280  REG_DWORD,
281  (BYTE *)&dwValue,
282  sizeof(dwValue));
283 
284  if (lResult != ERROR_SUCCESS)
285  {
286  /* Bail out and return FALSE if we fail */
287  RegCloseKey(hKey);
288  return FALSE;
289  }
290 
291  /* If we're here then we succeed, close the key and return TRUE */
292  RegCloseKey(hKey);
293  return TRUE;
294 }
#define TRUE
Definition: types.h:120
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
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:1091
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define KEY_WRITE
Definition: nt_native.h:1031
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:4895
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
RECT rcNormalPosition
Definition: winuser.h:3269
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by OSK_DlgClose(), and OSK_DlgProc().