[Original] limit the number of times the software is used

Source: Internet
Author: User

In some cases, such as a trial version ~~ And so on ~~ In fact, it is mainly a trial version, which limits the number of users to use.

We generally write some identification values to the Registry to accomplish this goal ~

 

The following is the implementation code:

VC platform MFC framework

   1:  unsigned char buffer[255]={0}; 
   2:  unsigned long length; 
   3:  unsigned long type; 
   4:  HKEY hKey; 
   5:   
   6:  RegOpenKey(HKEY_LOCAL_MACHINE, 
   7:      "Software//Classes//CLSID//{79AD74E9-1C65-408B-9880-E7937DB5AA93}", &hKey); 
   8:  RegQueryValueEx(hKey,"Num",NULL,&type,buffer,&length); 
   9:  RegCloseKey(hKey); 
  10:   
  11:  int Count; 
  12:  Count = atoi((const char*)buffer); 
  13:  if(Count == 0) 
  14:  { 
15: afxmessagebox ("this software is a trial version and can be used only five times ");
  16:      RegCreateKey(HKEY_LOCAL_MACHINE, 
  17:          "Software//Classes//CLSID//{79AD74E9-1C65-408B-9880-E7937DB5AA93}",&hKey); 
  18:      RegSetValueEx(hKey,"Num",0,REG_SZ,(const unsigned char *)"5",strlen("5")); 
  19:      RegCloseKey(hKey); 
  20:  } 
  21:  else if(Count == 1) 
  22:  { 
23: afxmessagebox ("full usage", mb_ OK, 1 );
  24:      exit(1); 
  25:  } 
  26:  else 
  27:  { 
  28:      char buf[255]={0}; 
  29:      Count -= 1; 
  30:      itoa(Count,buf,10); 
  31:      CString str; 
  32:      RegOpenKey(HKEY_LOCAL_MACHINE, 
  33:          "Software//Classes//CLSID//{79AD74E9-1C65-408B-9880-E7937DB5AA93}",&hKey); 
  34:      RegSetValueEx(hKey,"Num",0,REG_SZ,(const unsigned char*)buf,strlen(buf)); 
  35:      RegCloseKey(hKey); 
  36:  }    

 

The above ~~~

However, this method is easy to crack. It's okay to use the trial versions that are not very important .~~~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.