3 * regexpl - Console Registry Explorer
5 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 // Settings.cpp : implemetation of CSettings class - user customizable settings for Registry Explorer
26 #include "RegistryExplorer.h"
30 #define DEFAULT_NORMAL_TEXT_ATTRIBUTES FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
31 #define DEFAULT_COMMAND_TEXT_ATTRIBUTES FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
33 CSettings::CSettings()
37 m_wNormalTextAttributes
= DEFAULT_NORMAL_TEXT_ATTRIBUTES
;
38 m_wCommandTextAttributes
= DEFAULT_COMMAND_TEXT_ATTRIBUTES
;
41 CSettings::~CSettings()
43 VERIFY(SUCCEEDED(Clean()));
46 HRESULT
CSettings::Clean()
57 HRESULT
CSettings::Load(LPCTSTR pszLoadKey
)
71 LONG nError
= RegOpenKeyEx(HKEY_CURRENT_USER
,pszLoadKey
,0,KEY_QUERY_VALUE
,&hKey
);
72 if (nError
!= ERROR_SUCCESS
)
75 nError
= RegQueryValueEx(hKey
,PROMPT_VALUE_NAME
,NULL
,&dwType
,NULL
,&dwSize
);
76 if (nError
== ERROR_SUCCESS
&& dwType
== REG_SZ
)
78 m_pszPrompt
= (TCHAR
*) new BYTE
[dwSize
];
85 nError
= RegQueryValueEx(hKey
,PROMPT_VALUE_NAME
,NULL
,&dwType
,(BYTE
*)m_pszPrompt
,&dwSize
);
86 if (nError
!= ERROR_SUCCESS
|| dwType
!= REG_SZ
)
98 dwSize
= sizeof(DWORD
);
99 nError
= RegQueryValueEx(hKey
,NORMAL_TEXT_ATTRIBUTES_VALUE_NAME
,NULL
,&dwType
,(BYTE
*)&w
,&dwSize
);
100 if (nError
!= ERROR_SUCCESS
|| dwType
!= REG_DWORD
)
106 m_wNormalTextAttributes
= (WORD
)w
;
109 dwSize
= sizeof(DWORD
);
110 nError
= RegQueryValueEx(hKey
,COMMAND_TEXT_ATTRIBUTES_VALUE_NAME
,NULL
,&dwType
,(BYTE
*)&w
,&dwSize
);
111 if (nError
!= ERROR_SUCCESS
|| dwType
!= REG_DWORD
)
117 m_wCommandTextAttributes
= (WORD
)w
;
123 VERIFY(RegCloseKey(hKey
) == ERROR_SUCCESS
);
128 HRESULT
CSettings::Store(LPCTSTR pszLoadKey
)
133 LPCTSTR
CSettings::GetPrompt()
135 return m_pszPrompt
?m_pszPrompt
:CPrompt::GetDefaultPrompt();
138 WORD
CSettings::GetNormalTextAttributes()
140 return m_wNormalTextAttributes
;
143 WORD
CSettings::GetCommandTextAttributes()
145 return m_wCommandTextAttributes
;