How to add the software registration mark to the program? (Note: you do not want to add it to the database) Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061220125350203.html
My company has made a set of software,
You need to register to use it,
However, after successful registration, you do not want to save the registration success mark in the database or INI file,
I want to do it in a better way,
I wonder if you have any good solutions?
Thanks,
Put the registration code in the Registry and compare it each time.
Is there any relevant source code,
I have never done these things,
More advice,
No one saves the registration success mark
The
Follow up ~ Bangding.
The third floor is correct.
Practice: The user submits the hardware serial number of the local machine to you. After calculation, you get the registration code and hand it to the user for registration.
It doesn't matter where this registration code is put, even if a TXT is usedProgramDirectory, because the code is useless on other machines.
Each time the program runs, it compares the registration code with the actual registration code (also collects the hardware serial number for calculation.
Thank you,
Is there any other way,
I want to reveal this post today,
You can check the value in the Registry for registration:
Of course, the registration code in this program is casually written...
Procedure te_mainf.formcreate (Sender: tobject );
VaR re_id: integer;
Registertemp: Tregistry;
Inputstr, get_id: string;
Dy, clickedok: Boolean;
I: Double;
Label y, N;
Begin
DY: = false; // indicates whether the software has reached the registration period and whether it is allowed to continue using. If the value is false, it indicates that the software is allowed to be used.
Registertemp: = Tregistry. Create; // prepare to use the registry
With registertemp do
Begin
Rootkey: = HKEY_LOCAL_MACHINE; // stored under this root
If openkey ('Software \ Microsoft \ Windows \ CurrentVersion \ mark', true) Then // create a directory to store the flag value. Of course, it can also be stored in an existing Directory.
Begin
If valueexists ('gc _ id') Then // use the value of gc_id as a flag, first determine whether it exists
Begin
Re_id: = readinteger ('gc _ id'); // read the flag value
If (re_id <> 0) and (re_id <> 100) Then // if the flag value is 0, it indicates that it has been registered. If it is not 0 and the value is less than 100, it indicates that, although not registered, the number of allowed times has not reached.
Begin
Re_id: = re_id + 5; // the maximum value of the allowed flag is 100. If you add 5 at a time, the maximum value is 20.
Writeinteger ('gc _ id', re_id); // write the updated flag value to the Registry.
I: = (100-re_id)/5;
If application. MessageBox (pansichar ('the software you are using has not been registered, and '+ floattostr (I) +' usage times, do you want to register now? '), 'Prompt information', mb_yesno + mb_iconwarning) = idyes then
Begin
If I = 0 then
Application. Terminate
Else
Goto y;
End;
End;
If re_id = 0 Then goto N;
If re_id = 100 then DY: = true; // if the flag value has reached 100, you should register
End
Else
Writeinteger ('gc _ id', 5); // create a flag and set the initial flag value.
Re_id: = readinteger ('gc _ id ');
I: = (100-re_id)/5;
If application. MessageBox (pansichar ('the software you are using has not been registered, and '+ floattostr (I) +' usage times, do you want to register now? '), 'Prompt information', mb_yesno + mb_iconwarning) = idyes then
Begin
If I = 0 then
Application. Terminate
Else
Goto y;
End;
End;
If dy then
Y: Begin // If the Dy value is true, the user should be prompted to enter the registration code for registration.
Clickedok: = inputquery ('System prompt ', 'Enter the registration code:', inputstr );
If clickedok then
Begin
Get_id: = inttostr (83392582*2); // The registration code is 166785164, which is simple enough ......
If get_id = inputstr then
Begin
Writeinteger ('gc _ id', 0); // If the entered registration code is correct, set the flag value to 0, that is, the registered
Application. MessageBox ('Congratulations, software registration is successful! ',' Hint ', mb_ OK );
Closekey;
Free;
End
Else
Begin
Application. MessageBox ('registration code error! Please contact the author! ',' Warning ', mb_ OK + mb_iconstop );
Closekey;
Free;
Application. Terminate; // stop the program and refuse to continue using it.
End;
End
Else
Begin
Closekey;
Free;
Application. Terminate; // stop the program and refuse to continue using it.
End;
End;
End;
N: datamodule1: = tdatamodule1.create (Self );
If not assigned (e_loginf) then
E_loginf: = te_loginf.create (Self );
E_loginf.showmodal;
If e_loginf.modalresult = mrcancel then // check the return mode. If it is disabled or canceled, stop the operation.
Begin
Application. Terminate;
Exit;
End;
I don't know if it meets your requirements ~~