home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmRegister
- BackColor = &H00C0C0C0&
- Caption = "Registration Information"
- ClientHeight = 3705
- ClientLeft = 1230
- ClientTop = 2730
- ClientWidth = 5775
- Height = 4050
- Left = 1200
- LinkTopic = "Form1"
- ScaleHeight = 3705
- ScaleWidth = 5775
- Top = 2415
- Width = 5835
- Begin TextBox Text5
- Height = 285
- Left = 90
- TabIndex = 10
- Top = 3330
- Width = 5595
- End
- Begin TextBox Text4
- Height = 285
- Left = 90
- TabIndex = 8
- Top = 2700
- Width = 5595
- End
- Begin TextBox Text3
- Height = 285
- Left = 90
- TabIndex = 6
- Top = 2070
- Width = 5595
- End
- Begin TextBox Text2
- Height = 285
- Left = 90
- TabIndex = 4
- Top = 1440
- Width = 5595
- End
- Begin TextBox Text1
- Height = 285
- Left = 90
- TabIndex = 1
- Text = "<Target Company> : <Target User>"
- Top = 360
- Width = 5595
- End
- Begin CommandButton Command1
- Caption = "&Generate REGISTER.LIC"
- Default = -1 'True
- Height = 375
- Left = 90
- TabIndex = 2
- Top = 720
- Width = 5595
- End
- Begin Label Label5
- BackStyle = 0 'Transparent
- Caption = "rgrID readed from REGISTER.LIC"
- Height = 195
- Left = 90
- TabIndex = 9
- Top = 3060
- Width = 5595
- End
- Begin Label Label4
- BackStyle = 0 'Transparent
- Caption = "rgrNAME readed from REGISTER.LIC"
- Height = 195
- Left = 90
- TabIndex = 7
- Top = 2430
- Width = 5595
- End
- Begin Label Label3
- BackStyle = 0 'Transparent
- Caption = "CRC32 for REGISTER.LIC is"
- Height = 195
- Left = 90
- TabIndex = 5
- Top = 1800
- Width = 5595
- End
- Begin Label Label2
- BackStyle = 0 'Transparent
- Caption = "Registration &ID (rgrID) is"
- Height = 195
- Left = 90
- TabIndex = 3
- Top = 1170
- Width = 5595
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "&Enter name (rgrNAME) for registration"
- Height = 195
- Left = 90
- TabIndex = 0
- Top = 90
- Width = 5595
- End
- Option Explicit
- Sub Command1_Click ()
- Dim rgrNAME As String
- Dim rgrID As String
- Dim readNAME As String
- Dim readID As String
- Dim CRC As Long
- ' read the registration name
- rgrNAME = Trim$(text1.Text)
- ' check if the registration name exist
- If (Len(rgrNAME) = 0) Then
- ' no, display an error message
- MsgBox "Enter a name for registration", , Me.Caption
- ' bye
- Exit Sub
- End If
- ' disable the button
- Command1.Enabled = False
- ' *** replace <Your Password> with your own password (the password can be any char (chr$(1)->chr$(254))
- ' *** you can change the encrypt level
- rgrID = cToHexa(cEncrypt(rgrNAME, "<Your Password>", ENCRYPT_LEVEL_0))
- ' create the .LIC from the basis license file
- FileCopy "c:\register\register.cil", "c:\register\register.lic"
- ' open the .LIC file in append mode to add registration information
- Close #1
- Open "c:\register\register.lic" For Append Shared As #1
- ' add a CTRL+Z for using with cFileCRC32 in TEXT mode
- Print #1, Chr$(26)
- ' add a section header to use with cGetIni (* replace <Your Section> with your own section *)
- Print #1, "[<Your Section>]"
- ' add the the NAME of registration
- Print #1, "rgrNAME = "; rgrNAME
- ' add the the ID of registration
- Print #1, "rgrID = "; rgrID
- ' close the .LIC file
- Close #1
- ' display the ID
- Text2.Text = rgrID
- ' display the CRC32, file must be open in TEXT mode (read until CTRL+Z is encountered),
- ' you can save this CRC32 in your file on a LONG integer,
- ' compare the CRC32 calculated and the CRC32 in you file to see,
- ' if a modification has been made.
- CRC = cFileCRC32("c:\register\register.lic", OPEN_MODE_TEXT)
- Text3.Text = CRC
- ' read the rgrNAME (* replace <Your Section> with your own section *)
- readNAME = cGetINI("<Your Section>", "rgrNAME", "?", "c:\register\register.lic")
- Text4.Text = readNAME
- ' read the rgrID (* replace <Your Section> with your own section *)
- readID = cGetINI("<Your Section>", "rgrID", "?", "c:\register\register.lic")
- Text5.Text = readID
- ' check if the ID is correct and is the CRC32 is correct
- ' *** replace <Your Password> with your own password
- ' *** you can change the encrypt level in accordance with above
- If ((CRC = cFileCRC32("c:\register\register.lic", OPEN_MODE_TEXT)) And (readID = cToHexa(cEncrypt(rgrNAME, "<Your Password>", ENCRYPT_LEVEL_0)))) Then
- ' display validity message
- MsgBox "Registration ID is valid" & Chr$(13) & Chr$(13) & "REGISTERED INFO : " & readNAME, , Me.Caption
- Else
- ' display non-validity message
- MsgBox "Your license file is invalid." & Chr$(13) & Chr$(13) & "Program will be stopped.", , Me.Caption
- End If
- ' enable the button
- Command1.Enabled = True
- End Sub
-