ConfigurationManager
.cpp
#include "stdafx.h" #include "ConfigurationManager.h" using namespace MyAppName; ConfigurationManager::ConfigurationManager() { } ConfigurationManager::~ConfigurationManager() { } void ConfigurationManager::initDefaultSettings() { // Default settings // 알림 설정 _defaultSettings.insert(TSettingPair(make_pair(_T("show"), _T("NotifyAllow")), make_pair(_T("1"), _T("REG_DWORD")) )); _defaultSettings.insert(TSettingPair(make_pair(_T("show"), _T("NotifyDeny")), make_pair(_T("1"), _T("REG_DWORD")) )); _defaultSettings.insert(TSettingPair(make_pair(_T("show"), _T("NotifyTransparent")), make_pair(_T("85"), _T("REG_DWORD")) )); _defaultSettings.insert(TSettingPair(make_pair(_T("show"), _T("NoSplash")), make_pair(_T("1"), _T("REG_DWORD")) )); // 업데이트 설정 _defaultSettings.insert(TSettingPair(make_pair(_T("update"), _T("AutoUpdateTerm")), make_pair(_T("3"), _T("REG_DWORD")) )); _defaultSettings.insert(TSettingPair(make_pair(_T("update"), _T("AutoUpdateUse")), make_pair(_T("0"), _T("REG_DWORD")) )); _defaultSettings.insert(TSettingPair(make_pair(_T("update"), _T("ScheduledUpdateUse")), make_pair(_T("0"), _T("REG_DWORD")) )); _defaultSettings.insert(TSettingPair(make_pair(_T("update"), _T("ScheduledUpdateType")), make_pair(_T("0"), _T("REG_DWORD")) )); } BOOL ConfigurationManager::GetConfiguration(LPCTSTR szType, LPCTSTR szValue, CString& result) { CZsRegistry reg; CString regPath; regPath.Format(_T("%s\\%s"), INSTALLREGPATH, szType); return reg.GetValue(regPath, szValue, result); } BOOL ConfigurationManager::GetConfiguration(LPCTSTR szType, LPCTSTR szValue, DWORD& result) { CZsRegistry reg; CString regPath; regPath.Format(_T("%s\\%s"), INSTALLREGPATH, szType); return reg.GetValue(regPath, szValue, &result); } BOOL ConfigurationManager::SetConfiguration(LPCTSTR szType, LPCTSTR szValue, DWORD data) { CZsRegistry reg; CString regPath; regPath.Format(_T("%s\\%s"), INSTALLREGPATH, szType); return reg.SetValue(regPath, szValue, &data); } BOOL ConfigurationManager::SetConfiguration(LPCTSTR szType, LPCTSTR szValue, CString data) { CZsRegistry reg; CString regPath; regPath.Format(_T("%s\\%s"), INSTALLREGPATH, szType); return reg.SetValue(regPath, szValue, data.GetBuffer(0)); } BOOL ConfigurationManager::SetDefault(LPCTSTR szType, LPCTSTR szValue) { initDefaultSettings(); BOOL ret = FALSE; TStrStrPair retPair = _defaultSettings[make_pair(szType, szValue)]; CZsRegistry reg; CString regPath; regPath.Format(_T("%s\\%s"), INSTALLREGPATH, szType); if (lstrcmp(retPair.second, _T("REG_DWORD")) == 0) { DWORD data = _ttoi(retPair.first); ret = reg.SetValue(regPath, szValue, &data); } else { ret = reg.SetValue(regPath, szValue, retPair.first); } return ret; } std::pair
ConfigurationManager::GetDefault(LPCTSTR szType, LPCTSTR szValue) { initDefaultSettings(); TStrStrPair retPair = _defaultSettings[make_pair(szType, szValue)]; return retPair; }
ConfigurationManager
.h
#pragma once #include "stdafx.h" namespace Cert1 { typedef std::pair
TStrStrPair; typedef std::pair
TSettingPair; class ConfigurationManager { private: // Default settings std::map
_defaultSettings; void initDefaultSettings(); public: ConfigurationManager(); virtual ~ConfigurationManager(); static BOOL GetConfiguration(LPCTSTR szType, LPCTSTR szValue, CString& result); static BOOL GetConfiguration(LPCTSTR szType, LPCTSTR szValue, DWORD& result); BOOL SetConfiguration(LPCTSTR szType, LPCTSTR szValue, DWORD data); BOOL SetConfiguration(LPCTSTR szType, LPCTSTR szValue, CString data); BOOL SetDefault(LPCTSTR szType, LPCTSTR szValue); std::pair
GetDefault(LPCTSTR szType, LPCTSTR szValue); }; }
C++
MFC
환경설정
Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/C++/(MFC)ConfigurationManager
last modified 2012-12-07 14:12:49