mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 17:10:22 +00:00
Implemented: default settings, loading settings from registry key, settings for prompt, normal text colors and command text colors.
svn path=/trunk/; revision=1801
This commit is contained in:
parent
2b246092f3
commit
7f0a6dcd48
2 changed files with 169 additions and 0 deletions
146
rosapps/sysutils/regexpl/Settings.cpp
Normal file
146
rosapps/sysutils/regexpl/Settings.cpp
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
/* $Id: Settings.cpp,v 1.1 2001/04/16 05:03:29 narnaoud Exp $
|
||||||
|
*
|
||||||
|
* regexpl - Console Registry Explorer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2000,2001 Nedko Arnaoudov <nedkohome@atia.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Settings.cpp : implemetation of CSettings class - user customizable settings for Registry Explorer
|
||||||
|
|
||||||
|
#include "ph.h"
|
||||||
|
#include "RegistryExplorer.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include "Prompt.h"
|
||||||
|
|
||||||
|
#define DEFAULT_NORMAL_TEXT_ATTRIBUTES FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
|
||||||
|
#define DEFAULT_PROMPT_TEXT_ATTRIBUTES FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
|
||||||
|
|
||||||
|
CSettings::CSettings()
|
||||||
|
{
|
||||||
|
m_pszPrompt = NULL;
|
||||||
|
|
||||||
|
m_wNormalTextAttributes = DEFAULT_NORMAL_TEXT_ATTRIBUTES;
|
||||||
|
m_wPromptTextAttributes = DEFAULT_PROMPT_TEXT_ATTRIBUTES;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSettings::~CSettings()
|
||||||
|
{
|
||||||
|
VERIFY(SUCCEEDED(Clean()));
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CSettings::Clean()
|
||||||
|
{
|
||||||
|
if (m_pszPrompt)
|
||||||
|
{
|
||||||
|
delete m_pszPrompt;
|
||||||
|
m_pszPrompt = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CSettings::Load(LPCTSTR pszLoadKey)
|
||||||
|
{
|
||||||
|
HKEY hKey = NULL;
|
||||||
|
HRESULT hr;
|
||||||
|
DWORD dwType;
|
||||||
|
DWORD dwSize;
|
||||||
|
DWORD w;
|
||||||
|
|
||||||
|
hr = Clean();
|
||||||
|
if (FAILED(hr))
|
||||||
|
return hr;
|
||||||
|
|
||||||
|
hr = S_OK;
|
||||||
|
|
||||||
|
LONG nError = RegOpenKeyEx(HKEY_CURRENT_USER,pszLoadKey,0,KEY_QUERY_VALUE,&hKey);
|
||||||
|
if (nError != ERROR_SUCCESS)
|
||||||
|
return S_FALSE;
|
||||||
|
|
||||||
|
nError = RegQueryValueEx(hKey,PROMPT_VALUE_NAME,NULL,&dwType,NULL,&dwSize);
|
||||||
|
if (nError == ERROR_SUCCESS && dwType == REG_SZ)
|
||||||
|
{
|
||||||
|
m_pszPrompt = (TCHAR *) new BYTE[dwSize];
|
||||||
|
if (!m_pszPrompt)
|
||||||
|
{
|
||||||
|
hr = E_OUTOFMEMORY;
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
nError = RegQueryValueEx(hKey,PROMPT_VALUE_NAME,NULL,&dwType,(BYTE *)m_pszPrompt,&dwSize);
|
||||||
|
if (nError != ERROR_SUCCESS || dwType != REG_SZ)
|
||||||
|
{
|
||||||
|
delete m_pszPrompt;
|
||||||
|
m_pszPrompt = NULL;
|
||||||
|
hr = S_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwSize = sizeof(DWORD);
|
||||||
|
nError = RegQueryValueEx(hKey,NORMAL_TEXT_ATTRIBUTES_VALUE_NAME,NULL,&dwType,(BYTE *)&w,&dwSize);
|
||||||
|
if (nError != ERROR_SUCCESS || dwType != REG_DWORD)
|
||||||
|
{
|
||||||
|
hr = S_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_wNormalTextAttributes = (WORD)w;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwSize = sizeof(DWORD);
|
||||||
|
nError = RegQueryValueEx(hKey,PROMPT_TEXT_ATTRIBUTES_VALUE_NAME,NULL,&dwType,(BYTE *)&w,&dwSize);
|
||||||
|
if (nError != ERROR_SUCCESS || dwType != REG_DWORD)
|
||||||
|
{
|
||||||
|
hr = S_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_wPromptTextAttributes = (WORD)w;
|
||||||
|
}
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
|
||||||
|
if (hKey)
|
||||||
|
VERIFY(RegCloseKey(hKey) == ERROR_SUCCESS);
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CSettings::Store(LPCTSTR pszLoadKey)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPCTSTR CSettings::GetPrompt()
|
||||||
|
{
|
||||||
|
return m_pszPrompt?m_pszPrompt:CPrompt::GetDefaultPrompt();
|
||||||
|
}
|
||||||
|
|
||||||
|
WORD CSettings::GetNormalTextAttributes()
|
||||||
|
{
|
||||||
|
return m_wNormalTextAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
WORD CSettings::GetPromptTextAttributes()
|
||||||
|
{
|
||||||
|
return m_wPromptTextAttributes;
|
||||||
|
}
|
23
rosapps/sysutils/regexpl/Settings.h
Normal file
23
rosapps/sysutils/regexpl/Settings.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/* $Id: Settings.h,v 1.1 2001/04/16 05:03:29 narnaoud Exp $ */
|
||||||
|
|
||||||
|
#ifndef OPTIONS_H__a7382d2d_96b4_4472_974d_801281bd5327___INCLUDED
|
||||||
|
#define OPTIONS_H__a7382d2d_96b4_4472_974d_801281bd5327___INCLUDED
|
||||||
|
|
||||||
|
class CSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSettings();
|
||||||
|
~CSettings();
|
||||||
|
HRESULT Load(LPCTSTR pszLoadKey);
|
||||||
|
HRESULT Store(LPCTSTR pszStoreKey);
|
||||||
|
LPCTSTR GetPrompt();
|
||||||
|
WORD GetNormalTextAttributes();
|
||||||
|
WORD GetPromptTextAttributes();
|
||||||
|
private:
|
||||||
|
HRESULT Clean();
|
||||||
|
LPTSTR m_pszPrompt;
|
||||||
|
WORD m_wNormalTextAttributes;
|
||||||
|
WORD m_wPromptTextAttributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // #ifndef OPTIONS_H__a7382d2d_96b4_4472_974d_801281bd5327___INCLUDED
|
Loading…
Reference in a new issue