In an era of respecting software copyrights, the application of electronically registered software is becoming more and more widespread. Its appearance allows users to have a certain understanding of the unrestricted functions in the program, plays a role in promotion and dissemination, and also protects the vital interests of the producer. So, how do we create an electronic registration version of software?
After some exploration, the author simply created an electronic registration version of the software using VB.
Design principles
Use the "GetVolumeInformation" function in the API to extract the hard disk serial number of the user's machine as a feature code. This code is submitted during registration, and is calculated by the software copyright owner to give the registration code. Finally, the software user enters the registration code to complete the entire registration process ( To make the explanation simple, in this example, the feature code minus 101 is used as the registration code).
Create a new module file
Create a new module file and add the following declared statements and constants to the Module1.Bas module:
Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA"
(ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal
nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As
Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal
nFileSystemNameSize As Long) As Long
Global GetVal As Long
When programming, be careful to write the declaration statements on the same line.
Form settings
Add 2 text boxes on Form1 and set the Name property to Text1 and Text2 respectively; add another button and set the Name property to Command1.
add code
Add the following program code to the Form1_Load event of Form1:
Private Sub Form_Load()
Dim TempStr1 As String * 256
Dim TempStr2 As String * 256
Dim TempLon1 As Long
Dim TempLon2 As Long
………
'Read the information about whether to register or not. How to control it will not be explained here.
………
Call GetVolumeInformation("C:", TempStr1, 256, GetVal, TempLon1, TempLon2, TempStr2, 256)
Text1.Text = GetVal 'Extract the serial number of the local C drive to text box one
End Sub
Add the following program code to the Command1_Click event of Command1:
Private Sub Command1_Click()
If Text2 〈〉 CStr(GetVal) Then
MsgBox "The registration code is incorrect, please carefully check whether the input is correct."
Else
MsgBox "You have successfully registered, please restart the software."
………
(Write the correct registration information so that the software functions will not be restricted in the future. The specific method can be set according to personal preferences.)
………
End If
End Sub
At this point, we can run the program. You will find that we have simply implemented the function of using the hard disk serial number to create an electronically registered version of the software.