Open topic with navigation
See Also: OverviewImplementationPropertiesMethodsEvents
Refer to the Concept and Definitions topic Copy Protection for introductory information.
The copy protection functions of the PLUS system allow significant flexibility in controlling the illegal distribution of your applications. The following outlines the necessary source code to copy protect an application. Note that EZ Trial's Hardware Binding feature implements copy protection and may be a better alternative to this guide. Refer to Implementing EZ Trial and EZ Trigger instead.
The sample application Single User Copy Protection and License Transfer demonstrates one way to implement this form of licensing and is ready to compile and run for many programming languages. You may copy and paste this sample code into your application or use the step-by-step guide below.
One of the first steps is to determine how your application should react when an illegal copy is detected. Your application can take any of the following actions if the copy protection test fails:
Display an error message and exit.
Disable any number of critical functions.
Convert the Expiration Type to Demo - Say you decide that when your application is executed on an unauthorized computer, it will be converted into a 14-day demo notifying the client that such an event has taken place. The client would then be prompted to contact you for a Trigger Code to convert from the demo back to the retail product. There is no limit to the number of demo cycles that can occur as the Trigger Codes will be different for each copy that is converted to a demo.
Display the registration / unlock screen.
Source Code Changes
Add the PLUS ActiveX component to your project. See Adding PLUS ActiveX Interface to Your Applications
Drop the LFile control onto your main form.
Decide what type of hardware identification to use for the Computer ID Number. Refer to topic Computer ID Number for an explanation of the available algorithms. Do not use the algorithm COMPNO_NETNAME as this is reserved for network copy protection.
In the FormLoad event or startup of your application, set the property CPAlgorithm and, if appropriate, CPAlgorithmDrive and/or CPAlgorithmFile. Change UseEZTrigger property to True. Choose values for TCSeed and TCRegKey2Seed and set these properties. Set the LFPassword property. Using the method below, the password will not be a text string visible in your EXE file. In Visual Basic, this looks like:
LFile1.LFPassword = "p" & "as" & "sw" & "or" & "d"
Immediately after the above line, set the LFOpenFlags property to the value of 8. This tells the component to automatically create the License File if it is missing. In Visual Basic, this looks like:
LFile1.LFOpenFlags = 8
Immediately after the above line, set the LFName property. The LFName property should be set to the License File in your application directory (user chosen name). In Visual Basic, this looks like:
LFile1.LFName = App.Path & "\license.ini"
Add an Error event handler for LFile1, similar to what is listed below.
Private Sub LFile1_Error()
MsgBox "Error #" & LFile1.LastErrorNumber & _
" (" & LFile1.LastErrorString & ")"
Add a StatusChanged event handler for LFile1 to determine the mode of the application.
Private Sub LFile1_StatusChanged(ByVal startup As Boolean)
' see if we passed the copy protection test
If LFile1.CPCheck(0) = 1 Then
' Everything checked out
' substitute your code here
mnuTools.Enabled = True
' substitute your code here
mnuTools.Enabled = False
MsgBox "This application must be unlocked " & _
"before it can be used. Please " & _
"contact XYZ Company for an activation code."
Add a Trigger event handler to display a message when the user enters a valid or invalid Trigger Code.
Private Sub LFile1_Trigger(ByVal event_num As Long, _
ByVal event_data As Long)
If event_num > 0 Then
MsgBox "Activation Complete!"
MsgBox "Invalid Code Entered!"
Add a menu option to display an EZ Trigger dialog box:
Private Sub mnuUnlock_Click()
' Display our phone unlock screen.
LFile1.ShowTriggerDlg Me.hwnd, 0, "", 0, 0
Set up Product Definition in LFEdit
Run LFEdit from Start / Programs / SoftwareKey Licensing System / PLUS. If using an evaluation copy, change the product name in the toolbar combo box to BasicCP. Otherwise, click Product Definition menu then Setup. Click Add to create a new definition or select an existing one and choose Properties. On the License File Tab, be sure to change the password to the same value that you used for the LFPassword property. Click on the Trigger Code tab. Be sure to change the Trigger Code seed and RegKey2Seed to the same values that you used for the TCSeed and TCRegKey2Seed properties, respectively. Click Ok to save all changes.
Run Your Application
The first time your application is executed on the client's computer, it will not have been unlocked. Therefore, it will fail the copy protection test and the "This application must be unlocked" message box will appear.
Activate the Application Using EZ Trigger™
Click on the menu option added to display the Trigger Code dialog. Write down the two numbers on the form. These two numbers are what your customer will give you by phone, fax, or e-mail. Run LFEdit. With the correct Product Definition selected in the toolbar, click on the Trigger Codes button (lock) on the toolbar. Select Code 30 and click Select. Enter the two numbers previously written down and click Generate. Write this number down. This is the unlock code that will be given to the customer. Minimize LFEdit and enter this code into the application. You should see the "Activation Complete" message appear.
You can also give Trigger Codes 27, 28, 29, 30, and 31. Trigger Code 32 is used to turn off a licensed computer. To learn about Unsupervised License Transfers using the Transfer method, refer to the sample application Single User Copy Protection and License Transfer.