|
-
January 6th, 2012, 12:28 PM
#2
Re: COleDateTime::ParseDateTime issues under XP using VC++ 6.0
I am having same issue with my application it works fine in WIN 2k but not working oin WIN XP and code I worked is as follow:
SetAvailability();
COleDateTime timeStart;
// COleDateTime timeEnd(30.0);
COleDateTimeSpan timePassed;
int daysLeft = 0;
HKEY hk;
DWORD dwDisp;
// Open the Registry key, if it doesn't exist, it will be created.
RegCreateKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\AVTRON MANUFACTURING\\ADDAPT\\PARAMETERS",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE | KEY_READ,
NULL,
&hk,
&dwDisp);
// Check to see if the product code has been set in the registry entry.
int iRetValProdCode =
RegQueryValueEx(hk,
"USR:App Name\\ProductCode",
NULL,
NULL,
NULL,
NULL);
CAddaptApp* pAddaptApp = (CAddaptApp*)AfxGetApp();
if(iRetValProdCode != ERROR_SUCCESS)
{
DWORD cbData = sizeof(pAddaptApp->m_dwProductCode);
RegQueryValueEx(hk,
"USR:App Name\\ProductCode",
NULL,
NULL,
(LPBYTE)&pAddaptApp->m_dwProductCode,
&cbData);
}
if(iRetValProdCode != ERROR_SUCCESS || pAddaptApp->m_dwProductCode == 0)
{
// Check to see if the install date has been set in the registry entry. If it doesn't exist, create
// the registry entry.
int iRetVal = RegQueryValueEx(hk,
"USR:App Name\\FirstInstallDateTime",
NULL,
NULL,
NULL,
NULL);
COleDateTime currDateTime = COleDateTime::GetCurrentTime();
if(iRetVal != ERROR_SUCCESS)
{
// Registry entry doesn't exist, create it, and set to the current date.
RegSetValueEx(hk,
"USR:App Name\\FirstInstallDateTime",
0,
REG_DWORD,
(LPBYTE) &currDateTime,
sizeof(currDateTime));
}
timeStart = COleDateTime::GetCurrentTime(); // Date and time of the installation.
DWORD cbData = sizeof(timeStart);
RegQueryValueEx(hk,
"USR:App Name\\FirstInstallDateTime",
NULL,
NULL,
(LPBYTE)&timeStart,
&cbData);
timePassed = COleDateTime::GetCurrentTime() - timeStart;
daysLeft = 30 - static_cast<int>(timePassed.GetTotalDays());
CString strMessage;
if (daysLeft <= 0)
{
CProductCodeDlg dlg;
dlg.DoModal();
if(pAddaptApp->m_dwProductCode != 0)
{
// Create the product code registry entry.
RegSetValueEx(hk,
"USR:App Name\\ProductCode",
0,
REG_DWORD,
(LPBYTE) &pAddaptApp->m_dwProductCode,
sizeof(pAddaptApp->m_dwProductCode));
}
else
{
return FALSE;
}
}
else
{
strMessage.Format(_T("ADDapt is operating under a trial license. \n")
_T("You have %d" " days to activate ADDapt with a valid license.\n")
_T("To activate, Please call Avtron Field Service at 000 000-1230 ext 1214. \n")
_T("Do you want to Proceed?"), daysLeft);
int iRespVal = AfxMessageBox(strMessage, MB_YESNO | MB_ICONEXCLAMATION);
// User selected No, close the application.
if(iRespVal == IDNO)
{
return FALSE;
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|