BOOL CPromptApp::CheckFristTimeRun(CString& strStartTime)
{
SYSTEMTIME st = { 0 };
GetLocalTime(&st);
CTime tStart = CTime::GetCurrentTime() - CTimeSpan(0,0,0,GetTickCount()/1000);
strStartTime=tStart.Format("%Y-%m-%d-%H--%M-%S");
DWORD dwLastStartTime=0;
CRegKey key;
if(key.Open(HKEY_CURRENT_USER,_T("SOFTWARE\\DocGuarder\\StartComTime"),KEY_READ|KEY_WOW64_32KEY)==ERROR_SUCCESS)
{
key.QueryDWORDValue(_T("RecordTime"),dwLastStartTime);
//key.QueryValue(dwLastStartTime,_T("RecordTime"));
}
else
{
if (key.Create(HKEY_CURRENT_USER,_T("SOFTWARE\\DocGuarder\\StartComTime"),REG_NONE,REG_OPTION_NON_VOLATILE,KEY_WRITE|KEY_READ|KEY_WOW64_32KEY,NULL,0)==ERROR_SUCCESS)
{
if(key.Open(HKEY_CURRENT_USER,_T("SOFTWARE\\DocGuarder\\StartComTime"),KEY_READ|KEY_WRITE|KEY_WOW64_32KEY)==ERROR_SUCCESS)
key.QueryDWORDValue(_T("RecordTime"),dwLastStartTime);
}
}
key.Close();
CTime TheLastStartTime(dwLastStartTime);
CTimeSpan timeSpan=tStart-TheLastStartTime;
LONGLONG dwSeconds = timeSpan.GetTotalSeconds();
if (dwSeconds>=1)
{
DWORD dwtStart=0;
dwtStart=tStart.GetTime();
CRegKey Dokey;
if(Dokey.Open(HKEY_CURRENT_USER,TEXT("SOFTWARE\\DocGuarder\\StartComTime"),KEY_READ|KEY_WRITE|KEY_WOW64_32KEY)==ERROR_SUCCESS)
{
Dokey.SetDWORDValue(_T("RecordTime"),dwtStart);
//Dokey.SetValue(dwtStart,_T("RecordTime"));
}
Dokey.Close();
return TRUE;
}
return FALSE;
}