In fact, there are many ready-made software on the Internet. They can help you do some of the time control of shared software, such as 30 days, trial 100 times. Software written to Taiwanese now needs a trial version, because it is traditional, I want to do it online existing software << Phantom Encryption System >>, but the machine is killed in the next operation, I am newly installed with traditional 2000. Later, I thought I wrote it myself. The other party asked for 90 days, 150 times. I also want to use time synchronization methods (I have been implemented before), but considering some problems, think about there is not much necessary, anyway, this is not an important thing, it will give up. My idea is like this. When installing the software, get the system time, encrypt (I use DES), write to the registry, write into the INI file (both hands ready, strengthen security). Both files and registry are written to the same data, and if they are different, the software cannot run, and the write entry includes the installation time, the number of uses, and the usage time. Software runtime check time, file, and registry are written, if there is a problem, do not let reuse, and delete some data of the INI file and the registry (not all deleted to prevent it from installing again) . The application method is not safe, just to cope with general requirements, if high security is required, use other methods.
The following code simply demonstrates the processing of each part: 1. Write the encrypted data at the time of installation: (Encrypted Control) DES-> GenerateKey ("NEOWARTON20030731"); tdatetime * d = new tdatetime (Date ()) Ansistring Times, Date, FileName ;; Char Dir [256]; Times = "0"; DATE = DateTimetostr (* D); TIMES = des-> EncryptString (Times); Date = des-> encryptstring (date); / / install = des-> encryptstring (date); ansistring s = Times Date; outputdebugstring (s.c_str ()); filename = "// mysoft.ini"; getSystemDirectory (Dir, sizeof (dir)); filename = DIR FileName; IF (fileExists (fileEname)) {Application-> Terminate (); // if the ini file is alread exists exit;} else {tinifile * ini = new tinifile (filename); ini-> WritestString ("setup" , "Times", Times); INI-> Writestring ("setup", "Date", Date); Ini-> Writestring ("Setup", "Install", Date); delete ini; // Write Register Tregistry * REG = new Tregistry (); reg-> rootkey = hkey_local_machine; if ("// Software // Microsoft // Windows // CurrentVersion //Mysoft")) Application-> Terminate (); // if the Key Exists, Terminate Reg-> OpenKey ("// Software // Microsoft // WINDWARE / / CURRENTVERSION ///mysoft", true); REG-> WriteString ("Warning", "Dot Modify these Items! Otherwise, Your System Will NOT RUN! NEOWARTON2003XIAN "); REG-> WriteString (" Times ", Times); REG-> Writestring (" Date ", Date); REG-> WritString (" Install ", DATE); REG-> CloseKey (); DELETE REG;} II. Add the following code in Install Shield when installing: lauchapp (supportdir ^ "Test.exe", ") // TEST is omitted for the other code of the EXE file above, and when the application starts:
BOOL RT; TFORM1 * FM1 = New TFORM1 (NULL); // Trial version pop-up window, click on the trial return judgment result fm1-> showModal (); rt = fm1-> try_time; // has explende FM1; IF ( {MessageBox (null, "¥'' õ ¹ ¥ §'£ ¹¹ ¡¡£ £ £ ¹ ¡¡¥ ¸ª ¹ © ¨»» ¸ A/2ðáê¶r ¥ ¿|ª ª © i / N / n http://www.xxxxx.com "," ¯ «2 þ ¥ D33 ¥ ô ¨¤õ ¤õ¤õ¤õ", MB_OK MB_ICONITIONS; Application-> Terminate (); // ã3¬à3 ¥ îμ { §Ç return 0;} four, users click on the trial button, return to whether the expired BOOL value: // read the encrypted ini file in the system directory to read the time and date //iffenote exist, return false, if the time AND date wrong return false; // read data and then time from the register, where the data is also encrypted char dir [256]; AnsiString filename = "// mysoft.ini"; GetSystemDirectory (dir, sizeof (dir)); / / the ini fils is in the system directory filename = dir filename; if (! fileexists (fileename)) {Application-> MessageBox ("§ªo ¨t2¹¹¹ ¥» ¥ ó¶i|¤¤f «dªk × ï ¤W ¸ ¤ £ £ à|a ¨ï ¥ ¡¡/ n / n "," ¯ «« «¤õ ¤õð", MB_ICONERROR); hwnd h; h = findwindow (null, " Dnalarm ") ;: SendMessage (h, wm_cl OSE, 0, 0); OutputdebugString ("Go Here"); this-> try_time = true; close (); return;} tinifile * ini = new tinifile (filename); Ansistring Times, DateTime, InstallDay; Times = INi- > ReadString ("Setup", "Times", ""); DateTime = INI-> ReadString ("Setup", "Date", ""); InstallDay = INI-> ReadString ("setup", "install", " "); GetThepara (); ANSISTRING TT = TIMES_REG " | DATETIME_REG "| DATETIME_REG; ANSISTRING TTT = Times " | DateTime "| InstallDay;
IF ((TIMES_REG! = Times) || (DateTime_reg! = DATIME) || (InstallDay! = DATETIME_REG)) {this-> try_time = true;} else // ------------- ----------------------- {DES-> GenerateKey ("NEOWARTON20030731"); TIMES = des-> decryptstring (Times); DateTime = des-> DecryptString (datetime); installday = DES-> DecryptString (installday); times_reg = DES-> DecryptString (times_reg); datetime_reg = DES-> DecryptString (datetime_reg); installday_reg = DES-> DecryptString (installday_reg); tt = times_reg "|" DATETIME_REG "| DATETIME_REG; TTT = Times |" DateTime "| InstallDay; // |r2å|êà 'in @ | ¤ ¤¤¤¤ = StrtOINT (TIMES); TDATETIME * DT = New Tdate (Date ()); TDATETIME * S = New Tdate (strtodate); tdatetime * install = new tdate (strtodate (installday)); int TMP = * DT- * S; int TMP2 = * DT- * INSTALL; // int TMP3 = * S- * DT; IF ((TMP> = - 1) && (TMP <= 90) && (TMP2> = - 1) && (TMP2 <= 90) && (t <150)) {AnsiString times_tmp = DES-> EncryptString (IntToStr (StrToInt (times) 1)); AnsiString datetime_tmp = DES-> EncryptString (DateTimeToStr (* dt)); ini-> WriteString ( "setup", "times", times_tmp); Ini-> Writestring ("setup", "DATE", DATETIME_TMP); PUTTHEPARA (Times_TMP, DATETIME_TMP); this-> try_time = false;} else {// Write WRONG TIME; ANSISTRING TIMES_TMP = DES->
EncryptString (IntToStr (StrToInt (times) 200)); AnsiString datetime_tmp = DES-> EncryptString (DateTimeToStr (* dt 3000)); ini-> WriteString ( "setup", "times", times_tmp); ini-> WriteString ("Setup", "Date", DateTime_TMP; Putthepara (Times_TMP, DateTime_TMP); this-> try_time = true;}} delete ini; this-> close (); 5, INI file: [setup] Times = INAK6XCTEVW = Date = XOQVDLA R 2XTL4ZM567CQ == Install = KAP2X5LVCWAXTL4ZM567CQ == (Data has been encrypted) ..... six, the registry content is basically the same as the INI file content! The above code is just a preliminary, if you want to use, you need detailed modification. Because it is a traditional version, some comments are displayed as garbled, I have deleted the comment, the string in the message box is also garbled, you can change it! Please forgive! (Note, this article is just a simple method to meet the simple requirements of some friends, the code just achieve function, there are many problems, I am going to change, there is a good way to come out!) Welcome everyone to prompt good method. Author Blog:
http://blog.9cbs.net/warton/
Try to limit the number of software (Sword Spirit time and space -www.SwordElf.com) author: unknown from: Unknown total of 120 readers read the content of this article: Try to limit the number of software there are many ways, the key is the number of times this Where is the value stored. This article describes a method to store the number of trials by changing the time of the file, thereby restricting the trial of the software. First, by changing the file time to restrict the number of software in MS-DOS, the time of the file is saved by a 16-bit value, bit 15 ~ 11 is used to save the hour number, the bits 10 ~ 5 are used to save minutes Number, bit 4 ~ 0 is used to save the number of seconds. This 16-bit value can be used by us to save the number of trials. For example, in the sample program below, the author uses the number of saved number of minutes. Run the sample program, we can see that the number of times the file time is added 1, and the average person is difficult to detect. This method has a better concealment. Second, the interrupts involved in the sample program 1. The function of interrupting 21h 3DH Use: Open files for reading. Write or make up. Call register: AH = 3dh, al = 00h, DS: DX = file name; return register: CF reset - success, ax = file handle. CF set - error, ax = error code. 2. The function of interrupting 21h 3EH use: Forced clear all buffers, update the directory, so that the file handle is invalid. Call register: AH = 3EH, bx = file handle; return register: CF reset - success, AX is destroyed, CF set - error, ax = error code. 3. The function of the interrupt 21h is 57h, and the sub-function 00h is used: read the date and time of the last modified date. Call register: AX = 5700H, bx = file handle; return register: CF reset - success, cx = file time, DX = file date, CF set - error, ax = error code. 4. The function of the interrupt 21h is 57h, and the sub-function 01h is used: the date and time information of the file last modified will become a specified value. Call register: AX = 5701H, bx = file handle, cx = new time, DX = new date; return register: CF reset - success, CF set - error, ax = error code.