ReactOS  0.4.13-dev-259-g5ca9c9c
Settings.cpp
Go to the documentation of this file.
1 /*
2  * regexpl - Console Registry Explorer
3  *
4  * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 // Settings.cpp : implemetation of CSettings class - user customizable settings for Registry Explorer
23 
24 #include "ph.h"
25 #include "RegistryExplorer.h"
26 #include "Settings.h"
27 #include "Prompt.h"
28 
29 #define DEFAULT_NORMAL_TEXT_ATTRIBUTES FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
30 #define DEFAULT_COMMAND_TEXT_ATTRIBUTES FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
31 
33 {
34  m_pszPrompt = NULL;
35 
38 }
39 
41 {
43 }
44 
46 {
47  if (m_pszPrompt)
48  {
49  delete[] m_pszPrompt;
50  m_pszPrompt = NULL;
51  }
52 
53  return S_OK;
54 }
55 
57 {
58  HKEY hKey = NULL;
59  HRESULT hr;
60  DWORD dwType;
61  DWORD dwSize;
62  DWORD w;
63 
64  hr = Clean();
65  if (FAILED(hr))
66  return hr;
67 
68  hr = S_OK;
69 
70  LONG nError = RegOpenKeyEx(HKEY_CURRENT_USER,pszLoadKey,0,KEY_QUERY_VALUE,&hKey);
71  if (nError != ERROR_SUCCESS)
72  return S_FALSE;
73 
74  nError = RegQueryValueEx(hKey,PROMPT_VALUE_NAME,NULL,&dwType,NULL,&dwSize);
75  if (nError == ERROR_SUCCESS && dwType == REG_SZ)
76  {
77  m_pszPrompt = (TCHAR *) new (std::nothrow) BYTE[dwSize];
78  if (!m_pszPrompt)
79  {
80  hr = E_OUTOFMEMORY;
81  goto Exit;
82  }
83 
84  nError = RegQueryValueEx(hKey,PROMPT_VALUE_NAME,NULL,&dwType,(BYTE *)m_pszPrompt,&dwSize);
85  if (nError != ERROR_SUCCESS || dwType != REG_SZ)
86  {
87  delete m_pszPrompt;
88  m_pszPrompt = NULL;
89  hr = S_FALSE;
90  }
91  }
92  else
93  {
94  hr = S_FALSE;
95  }
96 
97  dwSize = sizeof(DWORD);
99  if (nError != ERROR_SUCCESS || dwType != REG_DWORD)
100  {
101  hr = S_FALSE;
102  }
103  else
104  {
106  }
107 
108  dwSize = sizeof(DWORD);
110  if (nError != ERROR_SUCCESS || dwType != REG_DWORD)
111  {
112  hr = S_FALSE;
113  }
114  else
115  {
117  }
118 
119 Exit:
120 
121  if (hKey)
122  VERIFY(RegCloseKey(hKey) == ERROR_SUCCESS);
123 
124  return hr;
125 }
126 
128 {
129  return S_OK;
130 }
131 
133 {
135 }
136 
138 {
140 }
141 
143 {
145 }
#define RegQueryValueEx
Definition: winreg.h:524
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
HRESULT Store(LPCTSTR pszStoreKey)
Definition: Settings.cpp:127
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
WORD GetCommandTextAttributes()
Definition: Settings.cpp:142
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define DWORD
Definition: nt_native.h:44
HRESULT Clean()
Definition: Settings.cpp:45
#define PROMPT_VALUE_NAME
LPTSTR m_pszPrompt
Definition: Settings.h:17
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
WORD m_wNormalTextAttributes
Definition: Settings.h:18
#define S_FALSE
Definition: winerror.h:2357
#define COMMAND_TEXT_ATTRIBUTES_VALUE_NAME
smooth NULL
Definition: ftsmooth.c:416
static LPCTSTR GetDefaultPrompt()
Definition: Prompt.cpp:90
WORD m_wCommandTextAttributes
Definition: Settings.h:19
LPCTSTR GetPrompt()
Definition: Settings.cpp:132
char TCHAR
Definition: xmlstorage.h:189
LONG HRESULT
Definition: typedefs.h:77
static void Exit(void)
Definition: sock.c:1331
unsigned short WORD
Definition: ntddk_ex.h:93
#define VERIFY(e)
Definition: ph.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD GetNormalTextAttributes()
Definition: Settings.cpp:137
unsigned char BYTE
Definition: mem.h:68
HRESULT Load(LPCTSTR pszLoadKey)
Definition: Settings.cpp:56
#define S_OK
Definition: intsafe.h:59
#define RegOpenKeyEx
Definition: winreg.h:520
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DEFAULT_COMMAND_TEXT_ATTRIBUTES
Definition: Settings.cpp:30
#define DEFAULT_NORMAL_TEXT_ATTRIBUTES
Definition: Settings.cpp:29
#define REG_DWORD
Definition: sdbapi.c:596
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
~CSettings()
Definition: Settings.cpp:40
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define NORMAL_TEXT_ATTRIBUTES_VALUE_NAME
#define REG_SZ
Definition: layer.c:22