Example3

Top  Previous  Next

EXAMPLE 3

 

Items covered in this topic

Description

The avlockunit.pas unit

The Registración Form

The RefreshStatus Procedure

Perform a practice with 3 PCs

Move a Primary License (PC1 --> PC2)

Register a PC as Secundary

Move Secondary License (PC3 --> PC1)

Register PC3 as Secundary

 

Description

 

In this example we will learn how to manage multiple users, the concept of primary and secondary PC and how to move the registration of one PC to another. This example uses only the advanced OLM. Below we see the forms and units that are part of this example:

 

example3_01

 

We have added the RegStatus form to display detailed registration data. Form1 is the main form of the application and the UserData form remain unchanged from example2. In the avlockunit.pas unit only removed one line, but in Regist, which is the registration form we've added new features to be described in detail below.

 

The avlockunit.pas unit

 

As in this case we do not start automatically the trial period we removed the line with the StartTrial call, since now the trial period starts from a button on the registration form. This was done because in this example to start the trial period is not the only option for the application, now could also be registered as a secondary PC linked to an existing primary record in the OLM.

 

The Registration Form

 

In this example we added several new features to this form, as shown below:

 

example3_02

 

As we can see, the lower area showing the registration status remains the same as the previous examples, but the area under "Register Now" has changed considerably. As you can see in the picture we have added a TPageControl component with multiple tabs, which are shown or hidden depending on the status of registration. Below you can see displayed all tabs:

 

example3_03

Until now in the previous examples we use only the primary registration. This is the unique option when (users = 1), but if we have more than one user, e.g. (users=3), we could register more than one PCs with the same license. The first PC should be registered as Primary, which generates a Primary record in the OLM. All other PCs should be registered as Secondary.

 

The RefreshStatus procedure

 

On the registration form we have this procedure which aims to adjust the controls of the form according to the registration status of the moment. For example, if the application is already registered must hide the "Trial" tab because it is no longer necessary. If the application is in a state not-registered must not display start and end date of the trial period and the remaining days to expire because they have no sense, etc.

 

 

procedure TRegForm.RefreshStatus;

var

 regdata:string;

 recordexists:boolean;

begin

 GetRegStatus;

 lstatus.Caption := keydata.strstatus;

 ltext.Caption:=msg1;

 ltext2.Caption:=msg2;

 ltext3.Caption := '';

 if AVLock.InstancesCtrl then

   ltext3.Caption :='There are active '+inttostr(AVLock.activeinstances.count)+' of '+

   inttostr(keydata.Instances)+' Instances allowed';

 if (keydata.Status = Registered) then begin

   ldate1.Caption := datetostr(keydata.Startdate);

   ldate2.Caption := datetostr(keydata.EndDate);

   pbar1.Position := barpos;

 end;

 

 BtnPriStep1.Caption := 'Deactivate';

 BtnSecStep1.Caption := 'Deactivate';

 tsTrial.TabVisible := (keydata.Status = Unregistered);

 if ((keydata.Status <> Registered) or

 not (keydata.KeyType in [Temporal, Permanent]))

 then begin //like unregistered, no valuable license

   tsPri.TabVisible := True;

   tsSec.TabVisible := True;

   tsMoveP.TabVisible := True;

   tsMoveS.TabVisible := True;

   //Step1

   BtnPriStep1.Enabled := False;

   BtnSecStep1.Enabled := False;

   //Step2

   pPriStep2.Visible := True;

   pSecStep2.Visible := True;

   if (keydata.Status = Moved) then

   begin

     //see if record exists

     regdata:=trim(AVLock.OnlineGetRegData(0));

     recordexists := (regdata <> '66') and (pos('|',regdata) > 0);

     if recordexists then begin

       if keydata.Primary then begin

         BtnPriStep1.Enabled :=True;

         BtnPriStep1.Caption := 'Restore';

       end else begin

         BtnSecStep1.Enabled :=True;

         BtnSecStep1.Caption := 'Restore';

       end;

     end;

   end;

 end else begin //valuable license

   tsPri.TabVisible := keydata.Primary;

   tsSec.TabVisible := False; //not keydata.Primary;

   tsMoveP.TabVisible := keydata.Primary;// and (keydata.KeyType in[Trial, Temporal, Permanent]);

   tsMoveS.TabVisible := (not keydata.Primary);// and (keydata.KeyType in[Trial, Temporal, Permanent]);

   //Step1

   BtnPriStep1.Enabled := (keydata.KeyType in[Temporal, Permanent]); //True;

   BtnSecStep1.Enabled := (keydata.KeyType in[Temporal, Permanent]); //True;

   //Step2

   pPriStep2.Visible := not BtnPriStep1.Enabled; //False;

   pSecStep2.Visible := not BtnSecStep1.Enabled; //False;

 end;

end;

 

 

Perform a practice with 3 PCs

 

In this practice we will see:

- How to move a Primary License to another PC

- How to register a PC as Secondary

- How to move a Secondary License to another PC

 

Consider a scenario with three PCs

 

PC1 with InstallCode D453ABDF635C : Registered as Primary

PC2 with InstallCode 5F5B5B1767DC  : Unregistered

PC3 with InstallCode 465ACB486AEC  : Unregistered

 

 

Assuming the application is already registered as a primary in PC1. See in Example1 how to register the application with a registration key and how to do it with the Dev-Panel in Example2. For this practice the application must be registered with (users = 3).

 

Since the application is already registered we will have the tabs "Primary" and "Move Primary" enabled:

 

example3_04

 

To check that we have (users = 3) see the registration data with the "Registration Data" button:

 

example3_14

 

Here we see that (users = 3) which is what we need. If we had fewer users we would have to increase them from the Dev-Panel as shown below:

 

example3_13

 

After saving the data with "Save Data" we have to restart the application on PC1 before continuing, but in this case it is not necessary because we already have 3 users.

 

Move a Primary License (PC1 --> PC2)

 

Back to our example PC1, we click the "Move Primary" tab.

 

The "Primary" tab lets you apply a new registration key and the "Move Primary" tab allows you to move the license to another PC. This operation requires two steps STEP1 and STEP2.

 

- Step 1 has a "Deactivate" button that lets you disable the origin PC.

- The Step2 must be done from the target PC where you must enter the InstallCode coming from the origin PC. In the image is not shown the STEP2 controls because right now the PC is still at registered status.        

 

example3_05

 

If we click on "Deactivate" a message is shown to inform that the primary registration has been disabled:

 

example3_06

 

This is the first step to move the license to another PC and if we press the button by mistake can turn back the operation with the "Restore" button. Now we see several tabs were enabled, this occurs because the license now is at moved state (much like to unregistered) and the application is available to take a new primary or secondary license.

 

example3_07

 

 

We turn now to another PC where you have the application at unregistered status. Note that the InstallCode for the first PC (PC1) was D453ABDF635C and the second (PC2) is 5F5B5B1767DC.

To complete the transfer of the license from PC1 to PC2, we must enter the InstallCode from PC1 into PC2 as seen in the image below:

 

example3_08

 

After clicking the Rectivate button will see the message "Primary Registration Reactivated". and clicking on "OK", we can see that the new registration status is exactly the same that was in the PC1 before starting the transfer process.

 

example3_09

 

If we now go to PC1, we see that the application is at Non-Registered status.

 

example3_10

 

If we start PC3 will also be at Not-Registered status

 

example3_11

 

Summing up we have:

 

PC1 : D453ABDF635C - Unregistered

PC2 : 5F5B5B1767DC - Registered as Primary

PC3 : 465ACB486AEC - Unregistered

 

Register a PC as Secundary

 

Now let's register PC3 as secondary. In the Secondary tab we have to enter the InstallCode of PC2 which is the primary PC.

 

example3_12

 

We click register and get the message "Registered". We click on 'Ok' and see the new status of PC3.

 

 

example3_15

 

Summing up we have:

 

PC1 : D453ABDF635C - Unregistered

PC2 : 5F5B5B1767DC - Registered as Primary

PC3 : 465ACB486AEC - Registered as Secondary linked to PC2

 

Below we see the records of PC2 and PC3 in the Dev-Panel:

 

example3_18

 

Move Secondary License (PC3 --> PC1)

 

Now let's move the License of PC3 to PC1. So we make the first step in PC3 with the "Deactivate" button:

 

example3_16

 

After click en "OK" we see the new status:

 

example3_17

 

As we see, the state is now "Moved to another computer". Thus this PC is available to be registered or be linked to another license. Now we need to go to PC1 to complete the process of moving the license. So we enter in PC1 the installcode from PC3 and click on the "Reactivate" button as seen in the image below:

 

example3_19

 

After click en "OK" we see the new status of PC1:

 

example3_20

 

Summing up we have:

 

PC1 : D453ABDF635C - Registered as Secondary linked to PC2

PC2 : 5F5B5B1767DC - Registered as Primary

PC3 : 465ACB486AEC - Unregistered

 

As now PC3 is at Unregistered status we can register it as secondary linked to PC2.

 

Register PC3 as Secundary

 

We repeat the process as explained in "Register a PC as a secondary". Place the InstallCode of PC2 in PC3 and click on "Register".

 

example3_12

 

Now we have all PCs registered:

 

PC1 : D453ABDF635C - Registered as Secondary linked to PC2

PC2 : 5F5B5B1767DC - Registered as Primary

PC3 : 465ACB486AEC - Registered as Secondary linked to PC2

 

If we now go to Dev-panel we can see the relationship between the three records:

 

example3_21