After trial period finish (30days) software moved to ProductCode Page, where technical support department will provide License # for rest of the period this product code generated in KeyCode generated.
Is there anyway I can provide that code which will allow end user to utilize the code for rest of the life of software.
Thank you very mucch.
Vijay Patel
After 30 days trail period over the Productcode Page will pop up, which will ask end user to insert product code in the form. This Product code will be generated in KEYCODE GENERATOR.
My question : since the trial period is over there is no return for customer. How can I give full permission on new software to end user from KEYGENERATOR and remove Date from registry and give new date to new software from code mentioned below:
#include "stdafx.h"
#include "keyCode.h"
#include "keyCodeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CKeyCodeDlg::CKeyCodeDlg(CWnd* pParent )
: CDialog(CKeyCodeDlg::IDD, pParent), m_dwProductCode(0), m_dwKeyCode(0)
{
m_Option1 = 1;
m_Option2 = m_Option3 = m_Option4 = m_Option5 = 0;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CKeyCodeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_PRODUCT_CODE, m_dwProductCode);
DDX_Text(pDX, IDC_KEY, m_dwKeyCode);
DDX_Check(pDX, IDC_RADIO1, m_Option1);
DDX_Check(pDX, IDC_RADIO2, m_Option2);
DDX_Check(pDX, IDC_RADIO3, m_Option3);
DDX_Check(pDX, IDC_RADIO4, m_Option4);
}
BEGIN_MESSAGE_MAP(CKeyCodeDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_BN_CLICKED(IDCANCEL, OnCancel)
ON_EN_CHANGE(IDC_KEY, OnKeyCodeEntry)
ON_BN_CLICKED(IDC_CALC, OnCalc)
ON_BN_CLICKED(IDC_RADIO1, OnOption)
ON_BN_CLICKED(IDC_RADIO2, OnOption)
ON_BN_CLICKED(IDC_RADIO3, OnOption)
ON_BN_CLICKED(IDC_RADIO4, OnOption)
END_MESSAGE_MAP()
BOOL CKeyCodeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
GetDlgItem(IDC_RADIO5)->EnableWindow(FALSE);
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE);
GotoDlgCtrl(GetDlgItem(IDC_KEY));
UpdateData(FALSE);
return FALSE; }
void CKeyCodeDlg::OnCalc()
{
int options = 32;
if(m_Option2)
options += 64;
if(m_Option3)
options += 128;
if(m_Option4)
options += 256;
if(m_Option5)
options += 512;
if(m_dwKeyCode>10)
{
m_dwProductCode = ( (m_dwKeyCode + 1001000) & 0x0ffc1f);
m_dwProductCode = m_dwProductCode + options;
}
UpdateData(FALSE);
}
void CKeyCodeDlg::OnOption()
{
if( m_Option2 || m_Option3 || m_Option4 )
{
m_Option1 = ((CButton*)GetDlgItem(IDC_RADIO1))->GetCheck();
if ( m_Option1 )
{ m_Option2 = m_Option3 = m_Option4 = m_Option5 = 0;
UpdateData(FALSE);
}
}
if( !(m_Option1 && m_Option2 && m_Option3 && m_Option4 && m_Option5) )
m_Option1 = 1;
m_Option2 = ((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck();
if(m_Option2 == 1)
m_Option1 = 0;
m_Option3 = ((CButton*)GetDlgItem(IDC_RADIO3))->GetCheck();
if(m_Option3 == 1)
m_Option1 = 0;
m_Option4 = ((CButton*)GetDlgItem(IDC_RADIO4))->GetCheck();
if(m_Option4 == 1)
m_Option1 = 0;
UpdateData(FALSE);
}
void CKeyCodeDlg::OnOK()
{
return;
}
void CKeyCodeDlg::OnKeyCodeEntry()
{
UpdateData(TRUE);
}
void CKeyCodeDlg::OnCancel()
{
CDialog::EndDialog(IDCANCEL);
}
void CKeyCodeDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CKeyCodeDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HBRUSH CKeyCodeDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_PRODUCT_CODE)
{
pDC->SetTextColor(RGB(255, 0, 0));
pDC->SetBkMode(TRANSPARENT);
}
return hbr;
}
******************************************************************************
******************************************************************************
Additional code for TimeSpan and registry entry is as follow:
SetAvailability();
COleDateTime timeStart;
COleDateTimeSpan timePassed;
int daysLeft = 0;
HKEY hk;
DWORD dwDisp;
RegCreateKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\AVTRON MANUFACTURING\\ADDAPT\\Parameters",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE | KEY_READ,
NULL,
&hk,
&dwDisp);
int iRetVal = RegQueryValueEx(hk,
"FirstInstallDateTime",
NULL,
NULL,
NULL,
NULL);
COleDateTime currDateTime = COleDateTime::GetCurrentTime();
if(iRetVal != ERROR_SUCCESS)
{
RegSetValueEx(hk,
"FirstInstallDateTime",
0,
REG_DWORD,
(LPBYTE) &currDateTime,
sizeof(currDateTime));
}
timeStart = COleDateTime::GetCurrentTime();
DWORD cbData = sizeof(timeStart);
RegQueryValueEx(hk,
"FirstInstallDateTime",
NULL,
NULL,
(LPBYTE)&timeStart,
&cbData);
timePassed = COleDateTime::GetCurrentTime() - timeStart;
daysLeft = 30 - static_cast<int>(timePassed.GetTotalDays());
CString strMessage;
if (daysLeft <= 0)
{
("To activate, please call Avtron Field Service \n"
"at 216-642-1230 ext 1214.\n"
"The %d days trial period started on the day you installed ADDapt.\n"
"The application will now close.", daysLeft);
CDialog dlg(IDD_PRODUCTCODE_DLG);
dlg.DoModal();
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 216 642-1230 ext 1214. \n")
_T("Do you want to Proceed?"), daysLeft);
int iRespVal = AfxMessageBox(strMessage, MB_YESNO | MB_ICONEXCLAMATION);
if(iRespVal == IDNO)
return FALSE;
}</int>