Notes for protecting Access Databases with Dinkey Pro/FD ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before doing anything it is a good idea to make a back-up of your database. It is possible to protect your database so well that you may have trouble accessing it yourself! 1. For Access 2007 and newer, view your form and then chose design view and view the properties for your form (choose the event tab). For versions before Access 2007, open your form in Design View. Now click on View > Properties and choose the "Event" tab. 2. You should now see the list of events associated with your form. Set the "On Open" entry to "=OpenStartup()". This will cause your database to launch this function when it is first loaded. 3. For Access 2007 and higher in the Database Tools tab launch the Visual Basic editor. 4. In the editor, select File > Import File... and choose the file DinkeyPro.bas to add this module to your project. Repeat this step to add DPSample.bas to your project as well. This VBA code will check for the Dinkey Pro/FD Dongle. If a dongle is found your database will continue to load. If a dongle is not found then it will display an error message and your database will not be loaded. 5. You will need to supply a locked copy of dpwin32.dll with your database. To support 64-bit versions of Access, you will also need to supply a locked dpwin64.dll. These DLLs should be located in the same directory as your database. If the relevant DLL is not found an error will occur. It is recommended that you rename the DLLs with names individual to you. In this case you must also modify the references to dpwin32.dll and dpwin64.dll in DinkeyPro.bas to use the new names. If you load your database at this point and dpwin32.dll is found it will return error 413: program not protected. 6. Lock the DLL(s) using the API method of protection using DinkeyAdd. You can specify the output path to be the folder that contains your database so that the locked DLLs are in the correct location. 7. You now have to do one more thing. Currently the user could load your database and then remove the call to check the protection and therefore have an unprotected copy. You must stop them doing this by saving your database as an ACCDE file (MDE file for Access prior to 2007). This compiles all the VBA code and stops it from being editable by an end user. You must save a copy of your original database otherwise you will not be able to make any changes either! You will distribute the ACCDE (MDE) file to your customers. To save your database as an ACCDE file, choose the Database Tools tab and choose "Make ACCDE". (for versions prior to 2007 choose "Save As" and change the type to a MDE file). Note - the VBA code in this sample is the same as the Visual Basic sample code we provide, except that we need to catch whether the DLL is missing or not (VB will terminate the program if the DLL is not found but VBA will display an error but continue to load the database). Note - You only need to copy the relevant sample code functions that you need. All comments in your VBA code are visible in your spreadsheet file so be careful what you say! You should remove all our comments. Note - Code marked with !!!! are places where you should customise the sample code so that it will work properly: * Change the SDSN value from 10101 to the value of your SDSN in the 10 main functions. * Change the MY_PRODCODE value to the Product Code in the dongle * Change the MyAlgorithm code (if you call a user algorithm) * Change the CryptDRIS code (if you encrypt the DRIS) * Change the CryptApiData (if you encrypt Data you send to our API) * Change the MyRWAlgorithm code (if encrypt Data you send to our API using the R/W algorithm) You will also probably want to replace our error messages (DisplayError) with your own.