ReactOS  0.4.12-dev-51-ge94618b
settings.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS On-Screen Keyboard
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Settings file for warning dialog on startup
5  * COPYRIGHT: Copyright 2018 BiČ™oc George (fraizeraust99 at gmail dot com)
6  */
7 
8 /* INCLUDES *******************************************************************/
9 
10 #include "osk.h"
11 #include "settings.h"
12 
13 /* FUNCTIONS *******************************************************************/
14 
16 {
17  HKEY hKey;
18  LONG lResult;
19  DWORD dwData;
20  DWORD cbData = sizeof(DWORD);
21 
22  /* Set the structure member to TRUE */
23  Globals.bShowWarning = TRUE;
24 
25  /* Open the key, so that we can query it */
27  L"Software\\Microsoft\\osk",
28  0,
29  KEY_READ,
30  &hKey);
31 
32  if (lResult != ERROR_SUCCESS)
33  {
34  /* Bail out and return FALSE if we fail */
35  return FALSE;
36  }
37 
38  /* Query the key */
39  lResult = RegQueryValueExW(hKey,
40  L"ShowWarning",
41  0,
42  0,
43  (BYTE *)&dwData,
44  &cbData);
45 
46  if (lResult != ERROR_SUCCESS)
47  {
48  /* Bail out and return FALSE if we fail */
49  RegCloseKey(hKey);
50  return FALSE;
51  }
52 
53  /* Load the data value (it can be either FALSE or TRUE depending on the data itself) */
54  Globals.bShowWarning = (dwData != 0);
55 
56  /* If we're here then we succeed, close the key and return TRUE */
57  RegCloseKey(hKey);
58  return TRUE;
59 }
60 
62 {
63  HKEY hKey;
64  LONG lResult;
65  DWORD dwData;
66 
67  /* If no key has been made, create one */
69  L"Software\\Microsoft\\osk",
70  0,
71  NULL,
72  0,
73  KEY_WRITE,
74  NULL,
75  &hKey,
76  NULL);
77 
78  if (lResult != ERROR_SUCCESS)
79  {
80  /* Bail out and return FALSE if we fail */
81  return FALSE;
82  }
83 
84  /* The data value of the subkey will be appended to the warning dialog switch */
85  dwData = Globals.bShowWarning;
86 
87  lResult = RegSetValueExW(hKey,
88  L"ShowWarning",
89  0,
90  REG_DWORD,
91  (BYTE *)&dwData,
92  sizeof(dwData));
93 
94  if (lResult != ERROR_SUCCESS)
95  {
96  /* Bail out and return FALSE if we fail */
97  RegCloseKey(hKey);
98  return FALSE;
99  }
100 
101  /* If we're here then we succeed, close the key and return TRUE */
102  RegCloseKey(hKey);
103  return TRUE;
104 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: msvc.h:34
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static HANDLE ULONG_PTR dwData
Definition: file.c:35
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:1094
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 LoadDataFromRegistry()
Definition: settings.c:15
#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:4917
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL SaveDataToRegistry()
Definition: settings.c:61
static const WCHAR L[]
Definition: oid.c:1087
unsigned char BYTE
Definition: ntddk_ex.h:96
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define REG_DWORD
Definition: sdbapi.c:539