ReactOS  0.4.15-dev-2720-g5ee0925
registry.c File Reference
#include "umandlg.h"
Include dependency graph for registry.c:

Go to the source code of this file.

Macros

#define ACCESS_UTILMAN_KEY   L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Accessibility\\Utility Manager"
 
#define UTILMAN_KEY   L"SOFTWARE\\Microsoft\\Utility Manager"
 
#define OSK_KEY   L"On-Screen Keyboard"
 
#define MAGNIFIER_KEY   L"Magnifier"
 

Functions

BOOL InitAppRegKey (IN HKEY hPredefinedKey, IN LPCWSTR lpszSubKey, OUT PHKEY phKey, OUT LPDWORD lpdwDisposition)
 
BOOL QueryAppSettings (IN HKEY hKey, IN LPCWSTR lpszSubKey, IN LPCWSTR lpszRegValue, OUT PVOID ReturnedData, IN OUT LPDWORD lpdwSizeData)
 
BOOL SaveAppSettings (IN HKEY hKey, IN LPCWSTR lpszRegValue, IN DWORD dwRegType, IN PVOID Data, IN DWORD cbSize)
 

Variables

REGISTRY_DATA RegData
 
REGISTRY_SETTINGS Settings
 

Macro Definition Documentation

◆ ACCESS_UTILMAN_KEY

#define ACCESS_UTILMAN_KEY   L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Accessibility\\Utility Manager"

Definition at line 19 of file registry.c.

◆ MAGNIFIER_KEY

#define MAGNIFIER_KEY   L"Magnifier"

Definition at line 22 of file registry.c.

◆ OSK_KEY

#define OSK_KEY   L"On-Screen Keyboard"

Definition at line 21 of file registry.c.

◆ UTILMAN_KEY

#define UTILMAN_KEY   L"SOFTWARE\\Microsoft\\Utility Manager"

Definition at line 20 of file registry.c.

Function Documentation

◆ InitAppRegKey()

BOOL InitAppRegKey ( IN HKEY  hPredefinedKey,
IN LPCWSTR  lpszSubKey,
OUT PHKEY  phKey,
OUT LPDWORD  lpdwDisposition 
)

@InitAppRegKey

Initialize a key. The function may not necessarily create it but open the key if it already exists. The disposition pointed lpdwDisposition determines that. This is a function helper.

Parameters
[in]hPredefinedKeyThe predefined key (e.g. HKEY_CLASSES_ROOT).
[in]lpszSubKeyThe path to the sub key to be created.
[out]phKeyA pointer that receives a handle to the key given by the function.
[out]lpdwDispositionA pointer that receives the disposition given by the function.
Returns
Returns TRUE if the function successfully created a key (or opened it), FALSE otherwise for failure.

Definition at line 50 of file registry.c.

54 {
55  LONG lResult;
56 
57  lResult = RegCreateKeyExW(hPredefinedKey,
58  lpszSubKey,
59  0,
60  NULL,
61  0,
62  KEY_WRITE,
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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyExW(IN HKEY hKey, IN LPCWSTR lpSubKey, IN DWORD Reserved, IN LPWSTR lpClass OPTIONAL, IN DWORD dwOptions, IN REGSAM samDesired, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes OPTIONAL, OUT PHKEY phkResult, OUT LPDWORD lpdwDisposition OPTIONAL)
Definition: registry.c:533
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define KEY_WRITE
Definition: nt_native.h:1031
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71

◆ QueryAppSettings()

BOOL QueryAppSettings ( IN HKEY  hKey,
IN LPCWSTR  lpszSubKey,
IN LPCWSTR  lpszRegValue,
OUT PVOID  ReturnedData,
IN OUT LPDWORD  lpdwSizeData 
)

@QueryAppSettings

Query the setting from the application's key. This is a function helper.

Parameters
[in]hKeyA handle to a key.
[in]lpszSubKeyThe path to a sub-key.
[in]lpszRegValueThe registry value where we need to get the data from.
[out]ReturnedDataAn arbitrary pointer that receives the returned data. Being arbitrary, the data can be of any type.
[in,out]lpdwSizeDataA pointer to the returned data pointed by ReturnedData parameter that retrieves the size of the aforementioned data, in bytes.
Returns
Returns TRUE if the function successfully loaded the value we wanted, FALSE otherwise for failure.

Definition at line 102 of file registry.c.

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 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, IN OUT PULONG lpcbData OPTIONAL)
Definition: registry.c:862
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define DPRINT
Definition: sndvol32.h:71

◆ SaveAppSettings()

BOOL SaveAppSettings ( IN HKEY  hKey,
IN LPCWSTR  lpszRegValue,
IN DWORD  dwRegType,
IN PVOID  Data,
IN DWORD  cbSize 
)

@SaveAppSettings

Save an application's setting data to the Registry. This is a function helper.

Parameters
[in]hKeyA handle to a key.
[in]lpszRegValueThe path to the sub key where the value needs to be created.
[out]dwRegTypeThe type of registry value to be created (e.g. a REG_DWORD).
[in]DataA pointer to an arbitrary data for the value to be set. Being arbitrary, the data can be of any type (in conformity with the registry type pointed by dwRegType) otherwise the function might lead to a undefined behaviour.
[in]cbSizeThe size of the buffer data pointed by Data parameter, in bytes.
Returns
Returns TRUE if the function successfully saved the application's setting, FALSE otherwise for failure.

Definition at line 166 of file registry.c.

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 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TRUE
Definition: types.h:120
LONG WINAPI RegSetValueExW(IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL, IN ULONG Reserved, IN ULONG dwType, IN const UCHAR *lpData, IN ULONG cbData)
Definition: registry.c:656
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define DPRINT
Definition: sndvol32.h:71

Variable Documentation

◆ RegData

REGISTRY_DATA RegData

Definition at line 14 of file registry.c.

◆ Settings

Definition at line 15 of file registry.c.