ReactOS  0.4.12-dev-36-g472787f
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.

Referenced by OSK_DlgInitDialog().

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 }
#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
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: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

◆ SaveDataToRegistry()

BOOL SaveDataToRegistry ( )

Definition at line 61 of file settings.c.

Referenced by OSK_DlgClose().

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 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
#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:1087
unsigned char BYTE
Definition: ntddk_ex.h:96
#define REG_DWORD
Definition: sdbapi.c:539