在线等:vc++6.0写入注册表内容,怎么从新启动就没有了
操作注册表代码
BOOL CShijianApp::InitInstance()
{
AfxEnableControlContainer();
//
TestTime tt;
CTime CurTime = CTime::GetCurrentTime();
CTime t = CurTime;
DWORD ShiYong=43200;
//检查软件是否第一次运行,如果是则设定限制时间
//我们这儿设定软件在当前时间两分分钟后禁用
if (!tt.IsInstalled())
{
//CTime t = CurTime + CTimeSpan(0,0,2,0);
tt.SetLimitTime(t.GetYear(),t.GetMonth(),t.GetDay(),
t.GetHour(),t.GetMinute(),t.GetSecond());
tt.SetLimitJianGe(ShiYong);
AfxMessageBox("第一次使用本软件",MB_OK);
}
else
{
//判断时间间隔是否小于等于0
DWORD JianGe1=0;
tt.GetLimitJianGe(JianGe1);
//判断是否已过使用时间
if(JianGe1<=0){
::AfxMessageBox("试用版已到期,请联系购买一个正版使用",MB_OK);
}
else{
//本次试用时间计算
::AfxMessageBox("第n次试用",MB_OK);
CTime lm;
tt.GetLimitTime(lm);
DWORD HuaFei=0;
long ShengXia=0;
if(lm>t){
::AfxMessageBox("向前更改时间",MB_OK);
ShengXia=0;
}
else{
HuaFei=(t-lm).GetTotalMinutes();
ShengXia=JianGe1-HuaFei;
}
//判断是否过期
if(ShengXia<=0)
{
ShengXia=0;
}
//写入注册剩余时间
tt.SetLimitJianGe(ShengXia);
//写入下次使用时刻
tt.SetLimitTime(t.GetYear(),t.GetMonth(),t.GetDay(),
t.GetHour(),t.GetMinute(),t.GetSecond());
//
}
}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CShijianDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}