Roger's Access Library Homepage
Forum Home Forum Home > Other Download Libraries > MS Access MVP Libraries > Tejpal, A.D.
  New Posts New Posts RSS Feed - TrialSet
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Please consider donating $1 per sample downloaded, (find out why here)


 Post Reply Post Reply
A.D. Tejpal View Drop Down
Microsoft MVP
Microsoft MVP

Joined: 30 Jun 2008
Status: Offline
Points: 192
Post Options Post Options   Thanks (0) Thanks(0)   Quote A.D. Tejpal Quote  Post ReplyReply Direct Link To This Post Topic: TrialSet
    Posted: 06 Jul 2008 at 10:27pm
Updated On:  01-Jun-2012
Sample Db - Explanatory Notes

     This sample demonstrates the process of preparing a front end db for trial use, by laying down the following settings -
        (a) Number of permitted uses.
        (b) Trial expiry date. 

    Out of (a) & (b) above, whichever falls earlier, displays a suitable message and causes the db to become unavailable for further use. 

    Count of uses is stored in a hidden table named T_Status. Even if the user gains access to this table, and tries to edit it, the overall settings are not easily disturbed as the criteria is linked to autonumber value which is controlled programmatically.

    Expiry date, start number and max permitted uses get embedded in VBA code - and therefore free from user interference, once the file is converted to mde.

Some interesting features for making the demo tamper-proof:
    1 - Essential values like TrialMode (Y/N), expiry date, max permitted uses, start value of autonumber, camouflaging offsets (for autonumber and date of last use) are hard coded in VBA module, which is not accessible to user in mde format.

    2 - Count of uses: 
    (a) Count of uses is tracked by autonumber value in table T_Status. It is a single record table and the record gets re-inserted after each use. 
    (b) Five digit starting value of this autonumber is generated on random basis and gets hard coded in VBA module.
    (c) The columns showing expiry date, max count and count of uses so far are redundant (mere diversionary role). Tampering of these values has no effect. 
    (d) If the user tries to interfere with autonumber value by re-creating the table, and the new autonumber happens to be less than the hard coded value of starting autonumber, the trial validity stands forfeited.

    3 - Additional safeguards:
    3.1 - A superstring made up of 55 digits is used to keep track of latest values of autonumber and the last use date. This string is generated by using random numbers. The autonumber and year / month / day parts of last use date are embedded within this string at different locations. As a further precaution, camouflaging offsets are added to the real values before implementing the embedment. These offsets, generated by using random numbers, are hard coded in VBA module. As a result, different copies of trial db, generated by using form F_LockSet, will have different values of offsets. Successful tampering of such a superstring is expected to be virtually impossible

    3.2 - The above super-string is stored in four separate ways as follows:
    (a) Database property
    (b) Project property
    (c) Registry key
    (d) Hidden system file in hidden system folder

    3.3 - On first run of trial db (signified by autonumber of table T_Staus being equal to hard coded value of starting autonumber coupled with the absence of database property, project property, registry key and special system hidden file), items 3.2 (a) to (d) above get created, duly populated with the superstring.

    3.4 - On each closing of form F_SwitchBoard, existing value of autonumber in table T_Status is incremented by one and along with current date, is embedded in freshly generated 55 digit superstring.

    3.5 - On each opening of form F_SwitchBoard, validity check is performed, covering:
    (a) Current autonumber in table T_Status should not be lower than the hard coded value of starting autonumber.
    (b) None of the special settings (database property, project property, registry key and special system hidden file) should be missing.
    (c) None of the four superstrings, stored in 3.2 (a) to (d) above, should show any sign of tampering and all the four superstrings should be identical.
    (d) Autonumber values as extracted from the superstrings from four different sources should all match the one in table T_Status.
    (e) Last use dates as extracted from various superstrings should equal each other and should never be higher than current date. This is meant to guard against re-setting of system clock backward.
    (f) Current autonumber should not exceed the value computed by adding max permitted uses to starting autonumber (both these settings are hard coded in VBA module).
    (g) Current date should not exceed the expiry date (hard coded in VBA module).

Before distributing an application with such features, following steps should be taken -
    1 - In your db, open VBA window and set reference to Microsoft Scripting RunTime. For versions up to Access 2003, set reference to DAO 3.6 as well. (This reference is not required for Access 2007 onwards as it is already built in). Come back to database window.

    2 - Import all objects from sample db into your db. These items are:
        (a) - Table T_Status
        (b) - Forms F_LockSet, F_Next and F_Switchboard
        (c) - General modules M_LockCheck and M_LockSet

    3 - Use form F_LockSet for making the desired settings for expiry date and max number of uses permitted. This will generate appropriate hard coded entries in VBA module M_LockSet.

    4 - Delete the form F_LockSet.

    5 - IMPORTANT: Right click table T_Status, open its properties window and make it hidden by setting its attributes to Hidden. 

    6 - Make sure that no form other than F_Switchboard is permitted to open independently. All forms should open only through F_SwithBoard and should also incorporate validity check for trial permissions. This is done by including suitable code in form's open event as demonstrated in sample form F_Next.

    7 - Set F_SwitchBoard as the start up form.

    8 - Go to VBA editor (press Alt + F11), save & compile (Debug > Compile).

    9 - Come out of VBA window and convert to mde (or accde) format as applicable. Conversion to mde or accde format will succeed only if the following conditions are satisfied:
        (a) All objects (tables, forms etc) are in closed condition.
        (b) The db is in a format matching the application. For example, if it is Access 2003 installation while the db is in access 2000 file format, it has first to be converted to Access 2003 file format. Similarly, on Access 2007 or 2010, the db should be in accdb format before attempting conversion to accde format.

As and when the db is to be made available for unrestricted use, create a fresh copy, using F_LockSet to generate the hard coded settings, after selecting "N" as TrialMode. Now, when the user opens form F_SwitchBoard, there will be no validity check and on closing of this form, all the special settings mentioned in para 3.2 (a) to (d) above (i.e. database property, project property, registry key and special system hidden file) will get deleted.

Version:    Access 2000 File Format

    DAO 3.6  for versions up to Access 2003 (For Access 2007 onwards, this reference is already built in)
    Microsoft Scripting RunTime

Download File >>uploads/37/

Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.