\r
// remove\r
bool Registry::remove(HKEY i_root, const tstring &i_path,\r
- const tstring &i_name)\r
+ const tstring &i_name)\r
{\r
-#ifdef USE_INI\r
- return false;\r
- if (i_name.empty())\r
- return false;\r
- return WritePrivateProfileString(_T("yamy"), i_name.c_str(), NULL, i_path.c_str()) == TRUE;\r
-#else // !USE_INI\r
- if (i_name.empty())\r
- return RegDeleteKey(i_root, i_path.c_str()) == ERROR_SUCCESS;\r
- HKEY hkey;\r
- if (ERROR_SUCCESS !=\r
- RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_SET_VALUE, &hkey))\r
- return false;\r
- LONG r = RegDeleteValue(hkey, i_name.c_str());\r
- RegCloseKey(hkey);\r
- return r == ERROR_SUCCESS;\r
-#endif // !USE_INI\r
+ if (i_root) {\r
+ if (i_name.empty())\r
+ return RegDeleteKey(i_root, i_path.c_str()) == ERROR_SUCCESS;\r
+ HKEY hkey;\r
+ if (ERROR_SUCCESS != RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_SET_VALUE, &hkey))\r
+ return false;\r
+ LONG r = RegDeleteValue(hkey, i_name.c_str());\r
+ RegCloseKey(hkey);\r
+ return r == ERROR_SUCCESS;\r
+ } else {\r
+ return false;\r
+ if (i_name.empty())\r
+ return false;\r
+ return WritePrivateProfileString(_T("yamy"), i_name.c_str(), NULL, i_path.c_str()) == TRUE;\r
+ }\r
}\r
\r
\r
// does exist the key ?\r
bool Registry::doesExist(HKEY i_root, const tstring &i_path)\r
{\r
-#ifdef USE_INI\r
- return true;\r
-#else // !USE_INI\r
- HKEY hkey;\r
- if (ERROR_SUCCESS !=\r
- RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey))\r
- return false;\r
- RegCloseKey(hkey);\r
- return true;\r
-#endif // !USE_INI\r
+ if (i_root) {\r
+ HKEY hkey;\r
+ if (ERROR_SUCCESS != RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey))\r
+ return false;\r
+ RegCloseKey(hkey);\r
+ return true;\r
+ } else {\r
+ return true;\r
+ }\r
}\r
\r
\r
// read DWORD\r
bool Registry::read(HKEY i_root, const tstring &i_path,\r
- const tstring &i_name, int *o_value, int i_defaultValue)\r
+ const tstring &i_name, int *o_value, int i_defaultValue)\r
{\r
-#ifdef USE_INI\r
- *o_value =\r
- GetPrivateProfileInt(_T("yamy"), i_name.c_str(), i_defaultValue, i_path.c_str());\r
- return true;\r
-#else // !USE_INI\r
- HKEY hkey;\r
- if (ERROR_SUCCESS ==\r
- RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey))\r
- {\r
- DWORD type = REG_DWORD;\r
- DWORD size = sizeof(*o_value);\r
- LONG r = RegQueryValueEx(hkey, i_name.c_str(), NULL,\r
- &type, (BYTE *)o_value, &size);\r
- RegCloseKey(hkey);\r
- if (r == ERROR_SUCCESS)\r
- return true;\r
- }\r
- *o_value = i_defaultValue;\r
- return false;\r
-#endif // !USE_INI\r
+ if (i_root) {\r
+ HKEY hkey;\r
+ if (ERROR_SUCCESS == RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey)) {\r
+ DWORD type = REG_DWORD;\r
+ DWORD size = sizeof(*o_value);\r
+ LONG r = RegQueryValueEx(hkey, i_name.c_str(), NULL, &type, (BYTE *)o_value, &size);\r
+ RegCloseKey(hkey);\r
+ if (r == ERROR_SUCCESS)\r
+ return true;\r
+ }\r
+ *o_value = i_defaultValue;\r
+ return false;\r
+ } else {\r
+ *o_value = GetPrivateProfileInt(_T("yamy"), i_name.c_str(), i_defaultValue, i_path.c_str());\r
+ return true;\r
+ }\r
}\r
\r
\r
// write DWORD\r
bool Registry::write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
- int i_value)\r
+ int i_value)\r
{\r
-#ifdef USE_INI\r
- DWORD ret;\r
- _TCHAR buf[GANA_MAX_PATH];\r
+ if (i_root) {\r
+ HKEY hkey;\r
+ DWORD disposition;\r
+ if (ERROR_SUCCESS !=\r
+ RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
+ REG_OPTION_NON_VOLATILE,\r
+ KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
+ return false;\r
+ LONG r = RegSetValueEx(hkey, i_name.c_str(), NULL, REG_DWORD,\r
+ (BYTE *)&i_value, sizeof(i_value));\r
+ RegCloseKey(hkey);\r
+ return r == ERROR_SUCCESS;\r
+ } else {\r
+ DWORD ret;\r
+ _TCHAR buf[GANA_MAX_PATH];\r
\r
- _stprintf(buf, _T("%d"), i_value);\r
- ret = WritePrivateProfileString(_T("yamy"), i_name.c_str(),\r
- buf, i_path.c_str());\r
- return ret != 0;\r
-#else // !USE_INI\r
- HKEY hkey;\r
- DWORD disposition;\r
- if (ERROR_SUCCESS !=\r
- RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
- REG_OPTION_NON_VOLATILE,\r
- KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
- return false;\r
- LONG r = RegSetValueEx(hkey, i_name.c_str(), NULL, REG_DWORD,\r
- (BYTE *)&i_value, sizeof(i_value));\r
- RegCloseKey(hkey);\r
- return r == ERROR_SUCCESS;\r
-#endif // !USE_INI\r
+ _stprintf(buf, _T("%d"), i_value);\r
+ ret = WritePrivateProfileString(_T("yamy"), i_name.c_str(),\r
+ buf, i_path.c_str());\r
+ return ret != 0;\r
+ }\r
}\r
\r
\r
// read string\r
bool Registry::read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
- tstring *o_value, const tstring &i_defaultValue)\r
+ tstring *o_value, const tstring &i_defaultValue)\r
{\r
-#ifdef USE_INI\r
- _TCHAR buf[GANA_MAX_PATH];\r
- DWORD len;\r
- len = GetPrivateProfileString(_T("yamy"), i_name.c_str(), _T(""),\r
- buf, sizeof(buf) / sizeof(buf[0]), i_path.c_str());\r
- if (len > 0)\r
- {\r
- *o_value = buf;\r
- return true;\r
- }\r
- if (!i_defaultValue.empty())\r
- *o_value = i_defaultValue;\r
- return false;\r
-#else // !USE_INI\r
- HKEY hkey;\r
- if (ERROR_SUCCESS ==\r
- RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey))\r
- {\r
- DWORD type = REG_SZ;\r
- DWORD size = 0;\r
- BYTE dummy;\r
- if (ERROR_MORE_DATA ==\r
- RegQueryValueEx(hkey, i_name.c_str(), NULL, &type, &dummy, &size))\r
- {\r
- if (0 < size)\r
- {\r
- Array<BYTE> buf(size);\r
- if (ERROR_SUCCESS == RegQueryValueEx(hkey, i_name.c_str(),\r
- NULL, &type, buf.get(), &size))\r
- {\r
- buf.back() = 0;\r
- *o_value = reinterpret_cast<_TCHAR *>(buf.get());\r
- RegCloseKey(hkey);\r
- return true;\r
+ if (i_root) {\r
+ HKEY hkey;\r
+ if (ERROR_SUCCESS ==\r
+ RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey)) {\r
+ DWORD type = REG_SZ;\r
+ DWORD size = 0;\r
+ BYTE dummy;\r
+ if (ERROR_MORE_DATA ==\r
+ RegQueryValueEx(hkey, i_name.c_str(), NULL, &type, &dummy, &size)) {\r
+ if (0 < size) {\r
+ Array<BYTE> buf(size);\r
+ if (ERROR_SUCCESS == RegQueryValueEx(hkey, i_name.c_str(),\r
+ NULL, &type, buf.get(), &size)) {\r
+ buf.back() = 0;\r
+ *o_value = reinterpret_cast<_TCHAR *>(buf.get());\r
+ RegCloseKey(hkey);\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ RegCloseKey(hkey);\r
+ }\r
+ if (!i_defaultValue.empty())\r
+ *o_value = i_defaultValue;\r
+ return false;\r
+ } else {\r
+ _TCHAR buf[GANA_MAX_PATH];\r
+ DWORD len;\r
+ len = GetPrivateProfileString(_T("yamy"), i_name.c_str(), _T(""),\r
+ buf, sizeof(buf) / sizeof(buf[0]), i_path.c_str());\r
+ if (len > 0) {\r
+ *o_value = buf;\r
+ return true;\r
+ }\r
+ if (!i_defaultValue.empty())\r
+ *o_value = i_defaultValue;\r
+ return false;\r
}\r
- }\r
- }\r
- RegCloseKey(hkey);\r
- }\r
- if (!i_defaultValue.empty())\r
- *o_value = i_defaultValue;\r
- return false;\r
-#endif // !USE_INI\r
}\r
\r
\r
// write string\r
bool Registry::write(HKEY i_root, const tstring &i_path,\r
- const tstring &i_name, const tstring &i_value)\r
+ const tstring &i_name, const tstring &i_value)\r
{\r
-#ifdef USE_INI\r
- DWORD ret;\r
+ if (i_root) {\r
+ HKEY hkey;\r
+ DWORD disposition;\r
+ if (ERROR_SUCCESS !=\r
+ RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
+ REG_OPTION_NON_VOLATILE,\r
+ KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
+ return false;\r
+ RegSetValueEx(hkey, i_name.c_str(), NULL, REG_SZ,\r
+ (BYTE *)i_value.c_str(),\r
+ (i_value.size() + 1) * sizeof(tstring::value_type));\r
+ RegCloseKey(hkey);\r
+ return true;\r
+ } else {\r
+ DWORD ret;\r
\r
- ret = WritePrivateProfileString(_T("yamy"), i_name.c_str(),\r
- i_value.c_str(), i_path.c_str());\r
- return ret != 0;\r
-#else // !USE_INI\r
- HKEY hkey;\r
- DWORD disposition;\r
- if (ERROR_SUCCESS !=\r
- RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
- REG_OPTION_NON_VOLATILE,\r
- KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
- return false;\r
- RegSetValueEx(hkey, i_name.c_str(), NULL, REG_SZ,\r
- (BYTE *)i_value.c_str(),\r
- (i_value.size() + 1) * sizeof(tstring::value_type));\r
- RegCloseKey(hkey);\r
- return true;\r
-#endif // !USE_INI\r
+ ret = WritePrivateProfileString(_T("yamy"), i_name.c_str(),\r
+ i_value.c_str(), i_path.c_str());\r
+ return ret != 0;\r
+ }\r
}\r
\r
\r
#ifndef USE_INI\r
// read list of string\r
bool Registry::read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
- tstrings *o_value, const tstrings &i_defaultValue)\r
+ tstrings *o_value, const tstrings &i_defaultValue)\r
{\r
- HKEY hkey;\r
- if (ERROR_SUCCESS ==\r
- RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey))\r
- {\r
- DWORD type = REG_MULTI_SZ;\r
- DWORD size = 0;\r
- BYTE dummy;\r
- if (ERROR_MORE_DATA ==\r
- RegQueryValueEx(hkey, i_name.c_str(), NULL, &type, &dummy, &size))\r
- {\r
- if (0 < size)\r
- {\r
- Array<BYTE> buf(size);\r
- if (ERROR_SUCCESS == RegQueryValueEx(hkey, i_name.c_str(),\r
- NULL, &type, buf.get(), &size))\r
- {\r
- buf.back() = 0;\r
- o_value->clear();\r
- const _TCHAR *p = reinterpret_cast<_TCHAR *>(buf.get());\r
- const _TCHAR *end = reinterpret_cast<_TCHAR *>(buf.end());\r
- while (p < end && *p)\r
- {\r
- o_value->push_back(p);\r
- p += o_value->back().length() + 1;\r
- }\r
- RegCloseKey(hkey);\r
- return true;\r
+ HKEY hkey;\r
+ if (ERROR_SUCCESS ==\r
+ RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey)) {\r
+ DWORD type = REG_MULTI_SZ;\r
+ DWORD size = 0;\r
+ BYTE dummy;\r
+ if (ERROR_MORE_DATA ==\r
+ RegQueryValueEx(hkey, i_name.c_str(), NULL, &type, &dummy, &size)) {\r
+ if (0 < size) {\r
+ Array<BYTE> buf(size);\r
+ if (ERROR_SUCCESS == RegQueryValueEx(hkey, i_name.c_str(),\r
+ NULL, &type, buf.get(), &size)) {\r
+ buf.back() = 0;\r
+ o_value->clear();\r
+ const _TCHAR *p = reinterpret_cast<_TCHAR *>(buf.get());\r
+ const _TCHAR *end = reinterpret_cast<_TCHAR *>(buf.end());\r
+ while (p < end && *p) {\r
+ o_value->push_back(p);\r
+ p += o_value->back().length() + 1;\r
+ }\r
+ RegCloseKey(hkey);\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ RegCloseKey(hkey);\r
}\r
- }\r
- }\r
- RegCloseKey(hkey);\r
- }\r
- if (!i_defaultValue.empty())\r
- *o_value = i_defaultValue;\r
- return false;\r
+ if (!i_defaultValue.empty())\r
+ *o_value = i_defaultValue;\r
+ return false;\r
}\r
\r
\r
// write list of string\r
bool Registry::write(HKEY i_root, const tstring &i_path,\r
- const tstring &i_name, const tstrings &i_value)\r
+ const tstring &i_name, const tstrings &i_value)\r
{\r
- HKEY hkey;\r
- DWORD disposition;\r
- if (ERROR_SUCCESS !=\r
- RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
- REG_OPTION_NON_VOLATILE,\r
- KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
- return false;\r
- tstring value;\r
- for (tstrings::const_iterator i = i_value.begin(); i != i_value.end(); ++ i)\r
- {\r
- value += *i;\r
- value += _T('\0');\r
- }\r
- RegSetValueEx(hkey, i_name.c_str(), NULL, REG_MULTI_SZ,\r
- (BYTE *)value.c_str(),\r
- (value.size() + 1) * sizeof(tstring::value_type));\r
- RegCloseKey(hkey);\r
- return true;\r
+ HKEY hkey;\r
+ DWORD disposition;\r
+ if (ERROR_SUCCESS !=\r
+ RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
+ REG_OPTION_NON_VOLATILE,\r
+ KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
+ return false;\r
+ tstring value;\r
+ for (tstrings::const_iterator i = i_value.begin(); i != i_value.end(); ++ i) {\r
+ value += *i;\r
+ value += _T('\0');\r
+ }\r
+ RegSetValueEx(hkey, i_name.c_str(), NULL, REG_MULTI_SZ,\r
+ (BYTE *)value.c_str(),\r
+ (value.size() + 1) * sizeof(tstring::value_type));\r
+ RegCloseKey(hkey);\r
+ return true;\r
}\r
+#endif //!USE_INI\r
\r
\r
// read binary\r
bool Registry::read(HKEY i_root, const tstring &i_path,\r
- const tstring &i_name, BYTE *o_value, DWORD i_valueSize,\r
- const BYTE *i_defaultValue, DWORD i_defaultValueSize)\r
+ const tstring &i_name, BYTE *o_value, DWORD *i_valueSize,\r
+ const BYTE *i_defaultValue, DWORD i_defaultValueSize)\r
{\r
- if (o_value && 0 < i_valueSize)\r
- {\r
- HKEY hkey;\r
- if (ERROR_SUCCESS ==\r
- RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey))\r
- {\r
- DWORD type = REG_BINARY;\r
- LONG r = RegQueryValueEx(hkey, i_name.c_str(), NULL, &type,\r
- (BYTE *)o_value, &i_valueSize);\r
- RegCloseKey(hkey);\r
- if (r == ERROR_SUCCESS)\r
- return true;\r
- }\r
- }\r
- if (i_defaultValue)\r
- CopyMemory(o_value, i_defaultValue,\r
- MIN(i_defaultValueSize, i_valueSize));\r
- return false;\r
+ if (i_root) {\r
+ if (i_valueSize) {\r
+ HKEY hkey;\r
+ if (ERROR_SUCCESS ==\r
+ RegOpenKeyEx(i_root, i_path.c_str(), 0, KEY_READ, &hkey)) {\r
+ DWORD type = REG_BINARY;\r
+ LONG r = RegQueryValueEx(hkey, i_name.c_str(), NULL, &type,\r
+ (BYTE *)o_value, i_valueSize);\r
+ RegCloseKey(hkey);\r
+ if (r == ERROR_SUCCESS)\r
+ return true;\r
+ }\r
+ }\r
+ if (i_defaultValue)\r
+ CopyMemory(o_value, i_defaultValue,\r
+ MIN(i_defaultValueSize, *i_valueSize));\r
+ return false;\r
+ } else {\r
+ return false;\r
+ }\r
}\r
\r
\r
// write binary\r
bool Registry::write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
- const BYTE *i_value, DWORD i_valueSize)\r
+ const BYTE *i_value, DWORD i_valueSize)\r
{\r
- if (!i_value)\r
- return false;\r
- HKEY hkey;\r
- DWORD disposition;\r
- if (ERROR_SUCCESS !=\r
- RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
- REG_OPTION_NON_VOLATILE,\r
- KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
- return false;\r
- RegSetValueEx(hkey, i_name.c_str(), NULL, REG_BINARY, i_value, i_valueSize);\r
- RegCloseKey(hkey);\r
- return true;\r
+ if (i_root) {\r
+ if (!i_value)\r
+ return false;\r
+ HKEY hkey;\r
+ DWORD disposition;\r
+ if (ERROR_SUCCESS !=\r
+ RegCreateKeyEx(i_root, i_path.c_str(), 0, _T(""),\r
+ REG_OPTION_NON_VOLATILE,\r
+ KEY_ALL_ACCESS, NULL, &hkey, &disposition))\r
+ return false;\r
+ RegSetValueEx(hkey, i_name.c_str(), NULL, REG_BINARY, i_value, i_valueSize);\r
+ RegCloseKey(hkey);\r
+ return true;\r
+ } else {\r
+ return false;\r
+ }\r
}\r
-#endif //!USE_INI\r
\r
\r
//\r
static bool string2logfont(LOGFONT *o_lf, const tstring &i_strlf)\r
{\r
- // -13,0,0,0,400,0,0,0,128,1,2,1,1,Terminal\r
- tregex lf(_T("^(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),")\r
- _T("(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),")\r
- _T("(-?\\d+),(-?\\d+),(-?\\d+),(.+)$"));\r
- tsmatch what;\r
+ // -13,0,0,0,400,0,0,0,128,1,2,1,1,Terminal\r
+ tregex lf(_T("^(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),")\r
+ _T("(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+),")\r
+ _T("(-?\\d+),(-?\\d+),(-?\\d+),(.+)$"));\r
+ tsmatch what;\r
\r
- if (!boost::regex_match(i_strlf, what, lf))\r
- return false;\r
- o_lf->lfHeight = _ttoi(what.str(1).c_str());\r
- o_lf->lfWidth = _ttoi(what.str(2).c_str());\r
- o_lf->lfEscapement = _ttoi(what.str(3).c_str());\r
- o_lf->lfOrientation = _ttoi(what.str(4).c_str());\r
- o_lf->lfWeight = _ttoi(what.str(5).c_str());\r
- o_lf->lfItalic = (BYTE)_ttoi(what.str(6).c_str());\r
- o_lf->lfUnderline = (BYTE)_ttoi(what.str(7).c_str());\r
- o_lf->lfStrikeOut = (BYTE)_ttoi(what.str(8).c_str());\r
- o_lf->lfCharSet = (BYTE)_ttoi(what.str(9).c_str());\r
- o_lf->lfOutPrecision = (BYTE)_ttoi(what.str(10).c_str());\r
- o_lf->lfClipPrecision = (BYTE)_ttoi(what.str(11).c_str());\r
- o_lf->lfQuality = (BYTE)_ttoi(what.str(12).c_str());\r
- o_lf->lfPitchAndFamily = (BYTE)_ttoi(what.str(13).c_str());\r
- tcslcpy(o_lf->lfFaceName, what.str(14).c_str(), NUMBER_OF(o_lf->lfFaceName));\r
- return true;\r
+ if (!boost::regex_match(i_strlf, what, lf))\r
+ return false;\r
+ o_lf->lfHeight = _ttoi(what.str(1).c_str());\r
+ o_lf->lfWidth = _ttoi(what.str(2).c_str());\r
+ o_lf->lfEscapement = _ttoi(what.str(3).c_str());\r
+ o_lf->lfOrientation = _ttoi(what.str(4).c_str());\r
+ o_lf->lfWeight = _ttoi(what.str(5).c_str());\r
+ o_lf->lfItalic = (BYTE)_ttoi(what.str(6).c_str());\r
+ o_lf->lfUnderline = (BYTE)_ttoi(what.str(7).c_str());\r
+ o_lf->lfStrikeOut = (BYTE)_ttoi(what.str(8).c_str());\r
+ o_lf->lfCharSet = (BYTE)_ttoi(what.str(9).c_str());\r
+ o_lf->lfOutPrecision = (BYTE)_ttoi(what.str(10).c_str());\r
+ o_lf->lfClipPrecision = (BYTE)_ttoi(what.str(11).c_str());\r
+ o_lf->lfQuality = (BYTE)_ttoi(what.str(12).c_str());\r
+ o_lf->lfPitchAndFamily = (BYTE)_ttoi(what.str(13).c_str());\r
+ tcslcpy(o_lf->lfFaceName, what.str(14).c_str(), NUMBER_OF(o_lf->lfFaceName));\r
+ return true;\r
}\r
\r
\r
// read LOGFONT\r
bool Registry::read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
- LOGFONT *o_value, const tstring &i_defaultStringValue)\r
+ LOGFONT *o_value, const tstring &i_defaultStringValue)\r
{\r
- tstring buf;\r
- if (!read(i_root, i_path, i_name, &buf) || !string2logfont(o_value, buf))\r
- {\r
- if (!i_defaultStringValue.empty())\r
- string2logfont(o_value, i_defaultStringValue);\r
- return false;\r
- }\r
- return true;\r
+ tstring buf;\r
+ if (!read(i_root, i_path, i_name, &buf) || !string2logfont(o_value, buf)) {\r
+ if (!i_defaultStringValue.empty())\r
+ string2logfont(o_value, i_defaultStringValue);\r
+ return false;\r
+ }\r
+ return true;\r
}\r
\r
\r
// write LOGFONT\r
bool Registry::write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
- const LOGFONT &i_value)\r
+ const LOGFONT &i_value)\r
{\r
- _TCHAR buf[1024];\r
- _sntprintf(buf, NUMBER_OF(buf),\r
- _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s"),\r
- i_value.lfHeight, i_value.lfWidth, i_value.lfEscapement,\r
- i_value.lfOrientation, i_value.lfWeight, i_value.lfItalic,\r
- i_value.lfUnderline, i_value.lfStrikeOut, i_value.lfCharSet,\r
- i_value.lfOutPrecision, i_value.lfClipPrecision,\r
- i_value.lfQuality,\r
- i_value.lfPitchAndFamily, i_value.lfFaceName);\r
- return Registry::write(i_root, i_path, i_name, buf);\r
+ _TCHAR buf[1024];\r
+ _sntprintf(buf, NUMBER_OF(buf),\r
+ _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s"),\r
+ i_value.lfHeight, i_value.lfWidth, i_value.lfEscapement,\r
+ i_value.lfOrientation, i_value.lfWeight, i_value.lfItalic,\r
+ i_value.lfUnderline, i_value.lfStrikeOut, i_value.lfCharSet,\r
+ i_value.lfOutPrecision, i_value.lfClipPrecision,\r
+ i_value.lfQuality,\r
+ i_value.lfPitchAndFamily, i_value.lfFaceName);\r
+ return Registry::write(i_root, i_path, i_name, buf);\r
}\r