Running a dBL Application
from a CD-ROM
by Robert Bravery

Introduction

For a while now, I have read or heard about people wanting to know how to run their apps from a CD,  either for distributing a demo app, or to have their data reside on the CD, so the data cannot be changed.  Fortunately, I got an opportunity to put some of my ideas into practice to see if they would work.  A few of those ideas were either fully or in part inspired by the great thoughts of the Visual dBASE newsgroups.  By putting your mind to it, you can face many problems and find many solutions.

A Few Problems

Having your apps run from a CD is not without its problems.  Right from the word go, you need to be aware of some of these problems.  Some can be overcome by using work-arounds used, while others, because of their nature, must be accepted.

Keep in mind that when running an app from a CD, the speed of both loading and data access will be substantially slower than when running the app from your hard drive or even from your Lan connection.  So, when designing your application, keep in mind the lack of speed and design sensibly.

In order for your app to run, you will need to deploy the dBASE runtime files and, if you’ll be accessing any table data, the Borland Database Engine (BDE).  Here you need to decide whether to have the runtime and BDE files run from the CD or to “formally” install them on the hard drive with appropriate registry entries, or instead, to copy both the app and runtime/BDE files to a new folder on the hard drive and run everything from there.  Each of these has some impact on either speed or compatibility problems.

If you are using images, they can also be accessed from the CD.  But keep the file size down.  I have found that big image file sizes cause dBASE to crash if run from the CD.  Try to use JPEG files since they are a lot smaller.  Also, try to keep the file sizes below 50 Kb.  This is because the images take a long time to load from the CD, and there seems to be some kind of time-out associated with running apps from the CD.

Gathering the Files

Create and compile your app.  Unless it’s unavoidable, do not link your graphic images into your exe.  Design a CD folder structure. If possible, create separate folders for data and images.  Make sure that your paths to these folders are correct so that your app can find the data and images on the CD.  Next, gather together the dBASE runtime files.  These files need to be put into the root directory of the CD along with the app and the BDE.  If only the data files will remain on the CD, then you would need to create an install program for the runtime and BDE files.  The list of runtime files can be obtained in your dBASE /Bin directory.

Table of Runtime files for Visual dBASE 7.x
 
  File Name for VdB 7.5 Explanation
  VDB7RUN.EXE Core dBASE runtime file
  VDB70009.DLL Default English Language Library
  VDB70007.DLL German Language Library
  VDB70010LL Italian Language Library
  VDB7000a.DLL Spanish Language Library
  VDB7000c.DLL French Language Library
  RESOURCE.DLL Resource Library for icons, bitmaps, etc
     

Table of Runtime files for DB2K
 
  File Name for dB2K  Explanation
  DB2KRUN.EXE Core dB2K runtime file
  DB2Kr_en.DLL Default English Language Library
  DB2Kr_xx.DLL Runtime Library
  RESOURCE.DLL Resource Library for icons, bitmaps, etc
     

These files would need to be put into the root directory of the CD if that’s where the app’s exe file is, or into whichever CD folder contains the app’s exe file.  If you are going to run your application from a drive other than the CD, but want your data to be accessed from that CD, you can copy the runtime files (and the BDE files as well) to the folder where your application resides.  By having all of these files in the same folder, you don’t have to mess with the registry or any ini files, or be bothered with conflicts between merging BDE config files, or have to worry about other installed programs that also use the BDE, such as Delphi or Corel Suite.

Note about running a copy of the dB2K runtime files and the BDE: A dBASE exe file, when loaded, needs to find the dBASE runtime files and the BDE in order to run. The first place it looks for these files is in the same folder in which the exe file itself resides, and it doesn’t need registry information to do this. So, although it would waste hard drive space, for every dB2K app you have on the hard drive of your development machine, you could have a copy of the runtime/BDE files in each app’s folder and thus not need registry entries for these files. You can take advantage of this behavior when distributing a demo or other app on a CD — just include the runtime and BDE files in the same folder as the YourApp.exe file on the CD, and there will be no need to mess with registry settings. Otherwise, if you would prefer to run the runtime and BDE from the hard drive, you can use an install program such as Inno Setup to “formally” install the BDE and runtime files on the hard drive with their appropriate registry entries.  Read the other article in the dBulletin and Ken Mayer’s HowTo on Inno Setup.

The following is a list of files required for the BDE. The BDE is required for any table-related data access.  These files can be found in your BDE folder.
 
  Core BDE Files Comments
  IDASCI32.DLL For accessing ASCII files
  IDBAT32.DLL For batch movement of data
  IDDA3532.DLL For accessing Microsoft Access databases
  IDDAO32.DLL For accessing Microsoft Access databases
  IDDBAS32.DLL For accessing dBASE databases
  IDDR32.DLL For Data Repository (Paradox only)
  IDODBC32.DLL For BDE access to ODBC drivers
  IDPDX32.DLL For accessing Paradox databases
  IDQBE32.DLL QBE query engine
  IDR20009.DLL BDE resources
  IDAPI32.DLL Main BDE system DLL
  IDSQL32.DLL SQL query engine (including local SQL)
  IDPROV32.DLL For MIDAS providers
  Language Driver Files  
  BANTAM.DLL Internationalization engine
  *.CVB Character set conversion files
  *.BTL Locales
  BLW32.DLL Expression engine
     

Other files that are also needed

Other files that are absolutely needed are your app.exe and any image files.  The image files can reside in their own image directory; just be careful about the path in VdB7.5 that you point to the correct folder to access those images.  In dB2K, the DEO takes care of this.

You would also need to create a YourApp.ini file, which you would place in the same directory as your YourApp.exe on the CD.  As with any compiled dBASE app, the ini file should have the same filename as the exe file. If you are installing your app onto the hard drive, make sure that your ini file is marked as “read only” and that there is no [Directory] section in it.  dBASE seems to like to write the last directory accessed to the ini file.  The next time you will try to run the application, it will fail because there is no registry entry for the runtime and the BDE files.  This is a very important thing to remember.  Also before you make your ini file “read only”, you need to add a section to your ini file.  Open your ini file in a text editor and add a BDE [IDAPI] section to it which names your BDE configuration file.  Something like this:
 
 
[IDAPI]
ConfigFile01=IDAPI32.cfg
   

After you have done this, create a new idapic32.cfg file or use an old one.  You can use the BDE configuration tool (bdecfg32.exe) found in your BDE directory, adding or deleting drivers and aliases as necessary.  Both these (.ini and .cfg) files would need to be put into the root directory of the CD or into the same directory as your app, if you are installing to the hard drive.

Next, if you want your app to run automatically when the CD is placed in the CD-ROM drive, you will also need to create an autorun.inf file and put it in the root of the CD.  The autorun.inf needs to have the execute (open) command in it with the name of the file needed to be executed.  Something like this:
 
 
[autorun]
open=Your_App.exe
   

Caution:  I have not tested any ActiveX (ocx) control running from the CD.  Normally, ocx files need to be registered.  If you are going to use an ocx, you need to have either an installation procedure or find some other way to register the ocx (this can be done from within dBASE by copying the ocx to a folder on the hard drive and ten using the run command to register the ocx).

Burning the CD

All that is left now is to create a CD image and to burn the CD.  I would close the CD after, as this would stop anyone from trying to overwrite or change files on the CD with their own CD-writer.

Conclusion

This might not be the only and best way of running a demo or other app from a CD, but I hope that this article provides you with a useful starting point.  If anyone has a better method or a refinement of the approach described here, it would be most welcome.

Using the techniques described in this article, other interesting  possibilities for dBASE come to mind.  For example, you could create your own auto-running application, or your own setup and install programs to distribute your applications.  Imagine having everything written, including the installation package, in dBASE.  It can be done!


Note: The author would like to thank Fabian Cevallos and David L. Stone, his proof-readers, for the improvements they brought to this text.