You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
3.0 KiB
126 lines
3.0 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: Settings.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of Settings.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "Settings.h"
|
|
#include "..\..\lglib\lgaux.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
CSettings::CSettings()
|
|
{
|
|
m_hKey = NULL;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSettings::CSettings") );
|
|
}
|
|
|
|
CSettings::~CSettings()
|
|
{
|
|
Destroy();
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSettings::~CSettings") );
|
|
}
|
|
|
|
BOOL CSettings::Create( LPCTSTR pKeyName )
|
|
{
|
|
Destroy();
|
|
|
|
TCHAR pPath[MAX_PATH];
|
|
::PathCombine( pPath, _T("Software"), pKeyName );
|
|
|
|
if( ::RegCreateKey( HKEY_CURRENT_USER, pPath, &m_hKey ) != ERROR_SUCCESS )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CSettings::Create"), _T("RegCreateKey failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSettings::Create"), _T("Succeeded") );
|
|
return TRUE;
|
|
}
|
|
|
|
void CSettings::Destroy()
|
|
{
|
|
if( m_hKey )
|
|
{
|
|
::RegFlushKey( m_hKey );
|
|
::RegCloseKey( m_hKey );
|
|
m_hKey = NULL;
|
|
}
|
|
}
|
|
|
|
BOOL CSettings::Load( LPCTSTR pSettingName, PVOID pData, INT nSize )
|
|
{
|
|
if( !m_hKey )
|
|
return FALSE;
|
|
|
|
if( !pSettingName || !pData || !nSize )
|
|
return FALSE;
|
|
|
|
return ::RegQueryValueEx( m_hKey, pSettingName, NULL, NULL, (PBYTE)pData, (PDWORD)&nSize ) == ERROR_SUCCESS;
|
|
}
|
|
|
|
BOOL CSettings::Save( LPCTSTR pSettingName, PVOID pData, INT nSize )
|
|
{
|
|
if( !m_hKey )
|
|
return FALSE;
|
|
|
|
if( !pSettingName || !pData || !nSize )
|
|
return FALSE;
|
|
|
|
return ::RegSetValueEx( m_hKey, pSettingName, 0UL, REG_BINARY, (PBYTE)pData, nSize ) == ERROR_SUCCESS;
|
|
}
|
|
|
|
BOOL CSettings::Save( LPCTSTR pSettingName, LPRECT pRect )
|
|
{
|
|
return Save( pSettingName, pRect, sizeof(RECT) );
|
|
}
|
|
|
|
BOOL CSettings::Load( LPCTSTR pSettingName, LPRECT pRect )
|
|
{
|
|
return Load( pSettingName, pRect, sizeof(RECT) );
|
|
}
|
|
|
|
BOOL CSettings::Load( LPCTSTR pSettingName, PINT pValue )
|
|
{
|
|
return Load( pSettingName, pValue, sizeof(INT) );
|
|
}
|
|
|
|
BOOL CSettings::Save( LPCTSTR pSettingName, INT nValue )
|
|
{
|
|
return Save( pSettingName, &nValue, sizeof(INT) );
|
|
}
|
|
|
|
BOOL CSettings::Load( LPCTSTR pSettingName, double* pValue )
|
|
{
|
|
return Load( pSettingName, pValue, sizeof(double) );
|
|
}
|
|
|
|
BOOL CSettings::Save( LPCTSTR pSettingName, double dValue )
|
|
{
|
|
return Save( pSettingName, &dValue, sizeof(double) );
|
|
}
|
|
|
|
BOOL CSettings::Save( LPCTSTR pSettingName, CLgDRect *pRect )
|
|
{
|
|
return Save( pSettingName, pRect, sizeof(CLgDRect) );
|
|
}
|
|
|
|
BOOL CSettings::Load( LPCTSTR pSettingName, CLgDRect *pRect )
|
|
{
|
|
return Load( pSettingName, pRect, sizeof(CLgDRect) );
|
|
}
|