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 .~~~