I have a program I need to protect from piracy. Has anyone got any suggestions as to the best way to go about this. Presumably some sort of "dongle" system is the way to go?


13 Years
Discussion Span
Last Post by nicentral

I don't even know what a dongle system is.... but I will say that going about protecting your program from piracy is going to be a difficult task. There have been hundreds of attempts, most of which fail. You can make it secure from the majority of users, who "don't know", but for a lot of people, piracy is a skill that they are going to keep practicing.


There is a way to create a thirty-day free trial (if that interests you). This hard codes the license key code into each copy of the application (you have to compile multiple times in order to give it to multiple users if you do not want them to share codes).

This code (below) is from a real application I wrote - in VB-6. I hope this helps you.


' Component : frmRegCode
' Project : NewNotes
' Description: [a form to register the Notepad for permanent use]
' Modified : 4/8/2005

Option Explicit
Dim strFirstRun As String, lngDaysRun As Long, strRegCode As String, _
strValidCode As String, strUser As String

Private Sub cmdSubmit_Click()
Rem: validate the registration code, save the code to the registry
strValidCode = "test code"

strRegCode = txtRegCode.Text
If strRegCode = strValidCode Then
lblWarning.Visible = False
Call VBA.SaveSetting(App.EXEName, "Copyright", "RegCode", strRegCode)
Me.Visible = False
Unload Me
frmNote.mnuHelpRegister.Enabled = False
lblWarning.ForeColor = vbRed
lblWarning.Caption = "Warning: Invalid Registration Code" & vbCrLf
lblWarning.Caption = lblWarning.Caption & "Please e-mail rhenerlau@yahoo.com"
lblWarning.Caption = lblWarning.Caption & vbCrLf & "to obtain a validated code"
lblWarning.Visible = True
End If
End Sub

Private Sub Form_Load()

strRegCode = VBA.GetSetting(App.EXEName, "Copyright", "RegCode", "")
strUser = VBA.GetSetting(App.EXEName, "Copyright", "UserID", "")
Rem: If the reg code is blank or invalid...
strFirstRun = VBA.GetSetting(App.EXEName, "Copyright", "strfirstrun", .Date$)
lngDaysRun = VBA.DateDiff("d", strFirstRun, VBA.Date$)
If (lngDaysRun > 30) Then
strRegCode = txtRegCode
End If
Me.cmdSubmit.Enabled = False
End Sub

Private Sub txtName_LostFocus()
End Sub

Private Sub txtName_Validate(Cancel As Boolean)
txtName = Trim$(txtName)
If IsNull(txtName) Then
Cancel = True
Cancel = False
End If
If Cancel = True Then
txtName.BackColor = vbRed
lblName.ForeColor = vbRed
txtName.BackColor = vbWhite
lblName.ForeColor = vbBlack
End If
End Sub

Private Sub txtRegCode_Validate(Cancel As Boolean)
txtRegCode = Trim$(txtRegCode)
If Not IsNull(txtRegCode.Text) Then
Cancel = False
Else: Cancel = True
End If
cmdSubmit.Enabled = Not Cancel
End Sub

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.