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?

Thanks.

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.

Richard

' 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
Else
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()
txtName_Validate
End Sub

Private Sub txtName_Validate(Cancel As Boolean)
txtName = Trim$(txtName)
If IsNull(txtName) Then
Cancel = True
Else
Cancel = False
End If
If Cancel = True Then
txtName.BackColor = vbRed
lblName.ForeColor = vbRed
txtName.SetFocus
Else
txtName.BackColor = vbWhite
lblName.ForeColor = vbBlack
txtRegCode.SetFocus
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

Member Avatar for nicentral

Just an FYI, a dongle-lock is a hardware based anti-piracy that usually goes on the parallel port, or USB port. Check out http://www.safenet-inc.com/ for different options for hardware security.

Andy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.