In the sample project GenRegCode, a registration code is created. The information taken is the UserName, CompanyName (optional), Rights (optional), ExpirationDate (optional), NumberRunTimes (optional), and NumberUsers (optional). This information is combined with the developers registration information, to create a unique registration code.
This function is taken from this screen in GenRegCode:
Private Sub cmdGenerateKey_Click()
Dim strReg As String, retVal As Long
Dim lExpireDate As Long, lNumUsers As Long, lNumRunTimes As Long
'Check for Expiration information
If Me.bUseExpire.Value >< 0 Then
lExpireDate = Me.sExpireDate.Value
Else
lExpireDate = -1
End If
'Check for User limits
If Me.bUsers.Value >< 0 Then
lNumUsers = CLng(Me.lNumUsers.Text)
Else
lNumUsers = -1
End If
'Check for RunTime limits
If Me.bUses.Value >< 0 Then
lNumRunTimes = CLng(Me.lNumUses.Text)
Else
lNumRunTimes = -1
End If
'Create the registration
retVal = RedRegister.CreateRegistration( _
UserName.Text, CompanyName.Text, Rights.Text, strReg, _
lExpireDate, lNumUsers, lNumRunTimes)
'Verify if registration was succesful
If retVal = True Then
Me.RegCodeStr.Text = strReg
ElseIf retVal = ERR_REDREG_BADUSERNAME Then
MsgBox "Username Must be at lease 2 characters"
Else
'Other error handling here
End If
End Sub