#include "Register.h"


#include "Windows.h"

void CMainFrame::IconMT()
{
 BOOL bIconFlag = 0;
 CTime t = CTime::GetCurrentTime();
 CString a;

 t = CTime::GetCurrentTime();// add 试用版本 有效期 30天
 
 int i = 0;
 char direct[256];
 int dirsize=256;
 char day[5];
 unsigned char value[256];
 HKEY keyRet;

 day [0] = NULL;

 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE//Microsoft//Windows//CurrentVersion")
  ,0,KEY_READ|KEY_WRITE,&keyRet)==ERROR_SUCCESS)
 {
  DWORD type=REG_SZ;
  DWORD size = 256;
  value[0] = 0;
  if (RegQueryValueEx(keyRet,_T("MProductId"),NULL,&type,value,&size) != ERROR_SUCCESS)
  {
   a = "000-0098007-05662";
   a = a + (LPCTSTR)t.Format(_T("%d"));
   strcpy(direct, (LPCSTR)CStringA((LPCWSTR)a));
   DWORD nowsize=strlen(direct);
   RegSetValueEx(keyRet,_T("MProductId"),NULL,REG_SZ,(unsigned char*)direct,nowsize);
  }
  sscanf((char*)value, "%d-0098007-05662%s", &i, day);

  if (i < 31)
  {
   a = day;
   if (a.Compare((LPCTSTR)t.Format(_T("%d"))) != 0)
    i++;
  }
  else
  {
   if(i < 100)
    i+=100;
  }
  strcpy(day, (char *)(LPCTSTR)t.Format(_T("%d")));
  sprintf((char*)value, "%03d-0098007-05662%s", i, day);
  DWORD nowsize=strlen((char*)value);
  RegSetValueEx(keyRet,_T("MProductId"),NULL,REG_SZ,(unsigned char*)value,nowsize);//MProductId
  RegCloseKey(keyRet);
 }
 if (i < 31)
  a.Format(_T("监控机Agnet试用版  您还有%d天"), 31-i);
 else
  if (i != 100)
  {
   a.Format(_T("监控机Agnet试用版已经到期了."));
  }
  else
   a.Format(_T("监控机Agnet"));

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐