Open topic with navigation
See Also: OverviewImplementationPropertiesMethodsEvents
Refer to the Concept and Definitions topic Network Floating Licensing for introductory information.
This type of network restriction allows you to regulate the number of concurrent users executing the application at one time. You decide the maximum number of workstations using your application simultaneously by setting the LAN Limit field in the License File.
The sample application Network Floating Licensing 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 systematic guide below.
Optional Copy Protection
It is possible to lock the application to the network server being used to avoid illegal copying. In most cases, the License File has only one entry with the Computer ID Number generated on the information derived from the server information using algorithm COMPNO_NETNAME for CPAlgorithm and the server drive or UNC path for CPAlgorithmDrive. If your software may be installed on a Peer-to-Peer network such as Novell Lite, Lantastic, or Windows Networking, the method Redir must be used to determine if the software is currently running from the peer server or from across a network. When executing the CPCheck method, switch the algorithm used in CPAlgorithm depending on from which hardware you are running. Use computer number from server COMPNO_HDSERIAL, COMPNO_WINPRODID, etc. Use the computer number from COMPNO_NETNAME for all workstations. This means that your application will need to be activated on the server and ONE of the workstations. After this is complete, all workstations should be able to access your software.
Network Semaphore Files
Using an exclusive file locking technique, Network Semaphore Files can be used to accurately count the number of current users of an application. You specify the path and file prefix to be used for the semaphore files. This path must be in a common network directory that is read/write accessible to all network clients. One semaphore file is created and locked per workstation using the path and prefix you specified, while appending a sequential number. The path is specified in the property SemPath, the prefix is specified in the property SemPrefix.
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.
In the FormLoad event or startup of your application, 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 SemPath property, which tells the control where the network semaphore files should be located. For our implementation, we want them to be in the same directory as the EXE file. In Visual Basic, this looks like:
LFile1.SemPath = App.Path & "\"
Immediately after the above line, set the CPAlgorithmDrive property to the drive that contains the EXE file. In Visual Basic, this looks like:
LFile1.CPAlgorithmDrive = App.Path
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. Note that this implementation automatically handles a peer-to-peer network.
Private Sub LFile1_StatusChanged(ByVal startup As Boolean)
Dim localdrive As Boolean
' assume we are running on a
' local drive (peer server)
localdrive = True
' see if we are authorized to run
' on this computer or network
If LFile1.Redir(App.Path) Then localdrive = False
If localdrive Then
' on peer servers, set copy protection
' ID algorithm to WINPRODID (128) and HDSERIAL (2)
' number (2) - 128+2=130
LFile1.CPAlgorithm = 130
' on peer clients, set copy protection ID
' algorithm to COMPNO_NETNAME (16)
LFile1.CPAlgorithm = 16
' see if we are authorized to run on
' this computer
If LFile1.CPCheck(0) <> 1 Then
' substitute your code here
mnuTools.Enabled = False
MsgBox "Application must be enabled " & _
"the first time it is executed. " & _
"Please contact the XYZ Corporation."
' now that we determined we can run
' on this computer, see if we can open
' a semaphore file for this workstation
If LFile1.SemOpen = 1 Then
' Everything checked out, load our main form
' and make sure the demo form is not loaded
' substitute your code here
mnuTools.Enabled = True
' substitute your code here
mnuTools.Enabled = False
MsgBox "User Limit Exceeded! " & _
"Please purchase more licenses."
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 EZTrial1. 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.
Create a License File in LFEdit
In LFEdit, click the New button on the toolbar. Click on the Expiration Fields Tab. Change the value of Users Allowed to the number of simultaneous users that this copy should allow. Save the License File. The proper value will be written to the License File. It is also possible to ship the application with 0 allowed users and use Trigger Codes to enable the proper number, depending on what the customer purchases.
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 27 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. If you did not pre-create a License File with the LAN users allowed, you will also need to give Code 33 to set the number of allowed users.
When shipping your software to customers, you can preset the Users Allowed field in the License File with the number of users they have purchased or simply ship with 1 and use a Trigger Code to change the value once they have the software installed. Trigger Codes 34 and 35 also apply to network licensing. If you run this application on a peer-to-peer network, you will need to give Code 27 once on the server and once from one of the workstations. If for some reason your application does not exit properly or the method SemClose is not called, rebooting the machine should free up the license by letting the network close the exclusive lock on the file. On older network operating systems, it may be necessary for the station that exited improperly to run the application and exit safely for the license to be freed up.