The stats are now written once per minute to the settings file.

This commit is contained in:
Kimmo Pekkola 2009-07-27 12:30:28 +00:00
parent b3fc191b58
commit 1dbfc85b01
3 changed files with 17 additions and 9 deletions

View File

@ -1837,6 +1837,7 @@ void CMeterWindow::Update(bool nodraw)
// Statistics // Statistics
CMeasureNet::UpdateStats(); CMeasureNet::UpdateStats();
Rainmeter->WriteStats(false);
if (!nodraw) if (!nodraw)
{ {

View File

@ -631,7 +631,7 @@ CRainmeter::~CRainmeter()
if (m_TrayWindow) delete m_TrayWindow; if (m_TrayWindow) delete m_TrayWindow;
WriteStats(); WriteStats(true);
GdiplusShutdown(m_GDIplusToken); GdiplusShutdown(m_GDIplusToken);
} }
@ -1636,11 +1636,17 @@ void CRainmeter::ReadStats()
/* /*
** WriteStats ** WriteStats
** **
** Writes the statistics to the ini-file ** Writes the statistics to the ini-file. If bForce is false the stats are written only once per minute.
** **
*/ */
void CRainmeter::WriteStats() void CRainmeter::WriteStats(bool bForce)
{ {
static DWORD lastWrite = 0;
if (bForce || (lastWrite + 1000 * 60 < GetTickCount()))
{
lastWrite = GetTickCount();
// Write the date for statistics // Write the date for statistics
WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_IniFile.c_str()); WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_IniFile.c_str());
@ -1649,6 +1655,7 @@ void CRainmeter::WriteStats()
WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str());
} }
}
/* /*
** ResetStats ** ResetStats

View File

@ -139,7 +139,7 @@ public:
void UpdateStats(); void UpdateStats();
void ReadStats(); void ReadStats();
void WriteStats(); void WriteStats(bool bForce);
void ResetStats(); void ResetStats();
BOOL GetCheckUpdate() { return m_CheckUpdate; }; BOOL GetCheckUpdate() { return m_CheckUpdate; };