ReactOS  0.4.12-dev-720-g6accaef
settings.c File Reference
#include "osk.h"
#include "settings.h"
Include dependency graph for settings.c:

Go to the source code of this file.

Functions

BOOL LoadDataFromRegistry ()
 
BOOL SaveDataToRegistry ()
 

Function Documentation

◆ LoadDataFromRegistry()

BOOL LoadDataFromRegistry ( )

Definition at line 15 of file settings.c.

16 {
17  HKEY hKey;
18  LONG lResult;
19  DWORD dwShowWarningData, dwLayout;
20  DWORD cbData = sizeof(DWORD);
21 
22  /* Set the structure members to TRUE */
23  Globals.bShowWarning = TRUE;
24  Globals.bIsEnhancedKeyboard = TRUE;
25 
26  /* Open the key, so that we can query it */
28  L"Software\\Microsoft\\osk",
29  0,
30  KEY_READ,
31  &hKey);
32 
33  if (lResult != ERROR_SUCCESS)
34  {
35  /* Bail out and return FALSE if we fail */
36  return FALSE;
37  }
38 
39  /* Query the key */
40  lResult = RegQueryValueExW(hKey,
41  L"ShowWarning",
42  0,
43  0,
44  (BYTE *)&dwShowWarningData,
45  &cbData);
46 
47  if (lResult != ERROR_SUCCESS)
48  {
49  /* Bail out and return FALSE if we fail */
50  RegCloseKey(hKey);
51  return FALSE;
52  }
53 
54  /* Load the data value (it can be either FALSE or TRUE depending on the data itself) */
55  Globals.bShowWarning = (dwShowWarningData != 0);
56 
57  /* Query the key */
58  lResult = RegQueryValueExW(hKey,
59  L"IsEnhancedKeyboard",
60  0,
61  0,
62  (BYTE *)&dwLayout,
63  &cbData);
64 
65  if (lResult != ERROR_SUCCESS)
66  {
67  /* Bail out and return FALSE if we fail */
68  RegCloseKey(hKey);
69  return FALSE;
70  }
71 
72  /* Load the dialog layout value */
73  Globals.bIsEnhancedKeyboard = (dwLayout != 0);
74 
75  /* If we're here then we succeed, close the key and return TRUE */
76  RegCloseKey(hKey);
77  return TRUE;
78 }
#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
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
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
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:3381

Referenced by wWinMain().

◆ SaveDataToRegistry()

BOOL SaveDataToRegistry ( )

Definition at line 80 of file settings.c.

81 {
82  HKEY hKey;
83  LONG lResult;
84  DWORD dwShowWarningData, dwLayout;
85 
86  /* If no key has been made, create one */
88  L"Software\\Microsoft\\osk",
89  0,
90  NULL,
91  0,
92  KEY_WRITE,
93  NULL,
94  &hKey,
95  NULL);
96 
97  if (lResult != ERROR_SUCCESS)
98  {
99  /* Bail out and return FALSE if we fail */
100  return FALSE;
101  }
102 
103  /* The data value of the subkey will be appended to the warning dialog switch */
104  dwShowWarningData = Globals.bShowWarning;
105 
106  lResult = RegSetValueExW(hKey,
107  L"ShowWarning",
108  0,
109  REG_DWORD,
110  (BYTE *)&dwShowWarningData,
111  sizeof(dwShowWarningData));
112 
113  if (lResult != ERROR_SUCCESS)
114  {
115  /* Bail out and return FALSE if we fail */
116  RegCloseKey(hKey);
117  return FALSE;
118  }
119 
120  /* The value will be appended to the layout dialog */
121  dwLayout = Globals.bIsEnhancedKeyboard;
122 
123  lResult = RegSetValueExW(hKey,
124  L"IsEnhancedKeyboard",
125  0,
126  REG_DWORD,
127  (BYTE *)&dwLayout,
128  sizeof(dwLayout));
129 
130  if (lResult != ERROR_SUCCESS)
131  {
132  /* Bail out and return FALSE if we fail */
133  RegCloseKey(hKey);
134  return FALSE;
135  }
136 
137  /* If we're here then we succeed, close the key and return TRUE */
138  RegCloseKey(hKey);
139  return TRUE;
140 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
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
#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 long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
#define REG_DWORD
Definition: sdbapi.c:539

Referenced by OSK_DlgClose(), and OSK_DlgProc().