Contents - Index


4.4.2 Automatic Mode Quick Start

We'll demonstrate how easy it is to create a demo/trial application with the Sheriff ActiveX Control.

Step 1

From the toolbox, drag and drop a Sheriff ActiveX control anywhere in your application's main form. Since Sheriff will be acting as an invisible control, turn the "Visible" property to "False".

Figure 1 below shows the properties of the Sheriff control.

Fig. 1

As you can see from the Figure 1, Sheriff categorises its properties into three types: Company Info, Product Info and Trial License. You can set those properties in the Properties Inspector window, as shown in Figure 1. Or you can set properties in with the property pages that Sheriff also provides.

Step 2

In the Property Inspector window, double click on "(Custom)". You will now see the property pages; click on the Product Info tab (see Figure 2 below).

Fig. 2


There are three options you need to set: Auto Trial, Auto Authorize and Auto Renew.

  1. With Auto Trial on, Sheriff will detect if the application has ever been licensed on the machine on which the application is being executed. If the application has not been licensed, Sheriff will automatically issue a trial licence that is pre-defined by the application's publisher. To define the trial licence, click on the "Trial License" tab as discussed in step 3.

  2. With Auto Authorize on, Sheriff will also detect if the application is licensed on the machine. If the machine is not licensed, instead of automatically issuing a trial licence, Sheriff will present a licensing dialog box to the end user as shown in Figure 5. Company information such as company name and address etc can be set in the "Company Info" property page, as discussed in step 4.
  3. Similar to Auto Authorize, as soon as the application's licence expires Sheriff will automatically present a renewing dialog box to the end user and asks the user to renew his licence with the application's publisher.

Step 3

If, in Step 2, you decided to let Sheriff automatically issue a trial licence you need to define your trial licence.

Click on the "Trial License" tab to bring up the licence properties that you can defined for your trial licence (see Figure 3 below):

Fig 3.


Step 4

If, in Step 2, you decided to let Sheriff automatically handle licence authorisation and/or renewal with its own dialog boxes, then you need to set up your company's information (to be displayed in the licence authorisation and renewal dialog boxes).

Click on the "Company Info" to display the property page (see Figure 4 below):

Fig. 4


Fig. 5

Step 5

Now that you have decided your licensing options, defined your trial licence and filled up your company information, it is time to write some code to put your application under Sheriff's protection.

To run Sheriff in the Automatic Mode, the minumum requirement is one method you need to call and one event you need to handle.

The method to call is CheckLicence. Edit the form load event of your application main form and enter the following code:

Private Sub Form_Load()
   Sheriff1.CheckLicence
End Sub

Step 6

We're almost done apart from one event from Sheriff that you need to handle.

If you have decided to go for Auto Trial, you need to handleOnChallengeevent. Sheriff fires upOnChallengebefore it can issue a trial licence to verify the identity of the application

Add OnChallenge event handler to the main form and enter the following codes:

Private Sub Sheriff1_OnChallenge(ByVal ChallengingData As String, ByRef ChallengedData As String)
   'we have to support challenge
   Dim Challenger As Object
   Set Challenger = CreateObject("Sheriff.Challenger")
   'Initialize the Challenger with secret codes
   Challenger.Secret1 = "0763198532076621"
   Challenger.Secret2 = "1854207641987532"
   Challenger.Secret3 = "2482159326044927"
   Challenger.Secret4 = "3739062895179618"

   hr = Challenger.CreateChallenge(ChallengingData, ChallengedData)

End Sub

Please note that the Secret Codes used in the demo are for evaluation. You need to replace them with your own Secret Codes when you have purchased a Sheriff Serial Number.

And that's all, your application is now protected!