本文整理汇总了C++中CConfigParser::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfigParser::Initialize方法的具体用法?C++ CConfigParser::Initialize怎么用?C++ CConfigParser::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConfigParser
的用法示例。
在下文中一共展示了CConfigParser::Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadStats
/*
** Reads statistics.
**
*/
void CMeasureNet::ReadStats(const std::wstring& iniFile, std::wstring& statsDate)
{
WCHAR buffer[48];
CConfigParser parser;
parser.Initialize(iniFile, NULL, L"Statistics");
const std::wstring& date = parser.ReadString(L"Statistics", L"Since", L"", false);
if (!date.empty())
{
statsDate = date;
}
uint32_t count = parser.ReadUInt(L"Statistics", L"Count", 0);
if (parser.GetLastDefaultUsed())
{
count = parser.ReadUInt(L"Statistics", L"NetStatsCount", 0);
}
c_StatValues.clear();
c_StatValues.reserve(count * 2);
for (uint32_t i = 1; i <= count; ++i)
{
ULARGE_INTEGER value;
_snwprintf_s(buffer, _TRUNCATE, L"In%u", i);
value.QuadPart = parser.ReadUInt64(L"Statistics", buffer, 0);
if (parser.GetLastDefaultUsed())
{
_snwprintf_s(buffer, _TRUNCATE, L"NetStatsInHigh%u", i);
value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0);
_snwprintf_s(buffer, _TRUNCATE, L"NetStatsInLow%u", i);
value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0);
}
c_StatValues.push_back(value.QuadPart);
_snwprintf_s(buffer, _TRUNCATE, L"Out%u", i);
value.QuadPart = parser.ReadUInt64(L"Statistics", buffer, 0);
if (parser.GetLastDefaultUsed())
{
_snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutHigh%u", i);
value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0);
_snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutLow%u", i);
value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0);
}
c_StatValues.push_back(value.QuadPart);
}
}
示例2: GetDlgItem
INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch (LOWORD(wParam))
{
case IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX:
{
BOOL state = !(Button_GetCheck((HWND)lParam) == BST_CHECKED);
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX);
EnableWindow(item, state);
Button_SetCheck(item, BST_UNCHECKED);
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_WALLPAPER_CHECKBOX);
EnableWindow(item, state);
Button_SetCheck(item, BST_UNCHECKED);
}
break;
case IDC_MANAGETHEMES_NAME_TEXT:
if (HIWORD(wParam) == EN_CHANGE)
{
WCHAR buffer[32];
int len = Edit_GetText((HWND)lParam, buffer, 32);
// Disable save button if no text or if backup
BOOL state = (len > 0 && _wcsicmp(buffer, L"@Backup") != 0);
EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state);
}
break;
case IDC_MANAGETHEMES_LIST:
if (HIWORD(wParam) == LBN_SELCHANGE)
{
// Ignore clicks that don't hit items
if (ListBox_GetCurSel((HWND)lParam) != LB_ERR)
{
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON);
EnableWindow(item, TRUE);
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_DELETE_BUTTON);
EnableWindow(item, TRUE);
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EDIT_BUTTON);
EnableWindow(item, TRUE);
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
int sel = ListBox_GetCurSel(item);
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
Edit_SetText(item, themes[sel].c_str());
}
}
break;
case IDC_MANAGETHEMES_SAVE_BUTTON:
{
WCHAR buffer[MAX_PATH];
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
Edit_GetText(item, buffer, MAX_PATH);
std::wstring theme = buffer;
std::wstring path = Rainmeter->GetThemePath();
CreateDirectory(path.c_str(), 0);
path += theme;
bool alreadyExists = (_waccess(path.c_str(), 0) != -1);
if (alreadyExists)
{
std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, theme.c_str());
if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES)
{
// Cancel
break;
}
}
else
{
// Make sure path exists
CreateDirectory(path.c_str(), NULL);
}
path += L"\\Rainmeter.thm";
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX);
if (Button_GetCheck(item) != BST_CHECKED)
{
if (!CSystem::CopyFiles(Rainmeter->GetIniFile(), path))
{
std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
Rainmeter->ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
break;
}
// Exclude unused skins
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX);
if (Button_GetCheck(item) == BST_CHECKED)
{
CConfigParser parser;
parser.Initialize(path);
// Remove sections with Active=0
//.........这里部分代码省略.........