RandyBeck.com


Paradox Table File Recovery

Paradox File Format

tvDMX for Turbo Pascal (just in case anyone still uses that)


TP-Links

email: rb@randybeck.com.


Member of the DCR
PROGRAMMING NOTES

I put a few items of interest to Delphi programmers here, and will be adding more periodically.


function QuestionBox()

I was hesitant to upload this one because I would think Delphi should already have something like it. They already have several dialog boxes for asking a question or displaying an error message. This function works along those lines.

QuestionBox asks a question and lets the user pick from up to five options:

function QuestionBox(AQuestion,AResponses: string) : integer;

AQuestion is simply a string with the question you ask:
    'Where would you like to go today?'

You can insert line feeds with the ^J character like this:
    'Where would you'+^J+'like to go today?'

AResponses is one string holding up to four responses separated by apostrophes (";").
    'Sail to Bermuda;Fly to Paris;Launch to Orbit'

The responses may also include "&" to indicate hotkeys.

It returns the numbers 1 through 5, based on the option selected, or 0 if the user cancelled or pressed Esc.

  Case QuestionBox('Where would you like to go?',
              'Sail to &Bermuda;Fly to &Paris;Launch to &Orbit')
  of
    1:   Dest := 'Bermuda';
    2:   Dest := 'Paris';
    3:   Dest := 'Orbit';
  else   Exit;  { user cancelled }
  end;

Note: You can have up to five responses.

The dialog box's caption is "Question" but it can be modified at the global variable QuestionBoxCaption.

The height of the question area can be modified at QuestionBoxPanelHeight.

Download QUESUNIT.zip  (2,171 bytes) -- July-1-2008.


Unit BDEreset;

This is for programmers still using the Borland Database Engine and who have encountered the inevitable Vista problems with their Delphi programs.

As you ought to know by now, the BDE defaults to placing its NET DIR in the root directory ("C:\"), which is not permitted under Vista.

BDEreset will check the NET DIR location, and move it into the common AppData folder if necessary. I haven't yet concluded that this is the best location, but I'm keeping it there for now. You may revise the source if you think otherwise.

Note: My first thought was to use the Windows Temporary folder, but I realized this may cause trouble if the user changes.

This unit must be declared at the top of the uses declarations so it will be initialized before other units. It will not work properly if the BDE is initialized first.

The NET DIR location is checked (and fixed if necessary) during the unit's initialization process. Once the unit has been added at a suitable position in your project, you don't need to do anything else with it.

Download BDEreset.pas  (4,868 bytes) -- June-4-2008.
            (revised June-9 and July-2-2008)

Note: I received a note on the About Delphi board that says it can't detect the application directory with limited user permission.  I'm caught off guard by this, as I had thought that common AppData would work fine, but it makes sense given that the unit actually creates a new folder under that one.  It now uses the folder that the BDE is in. -- July-2-2008


Unit MyInfo;

This unit has nine functions to return information about the user's PC. 

I try to limit this page to items that may be hard to find elsewhere. Although some of this stuff has become easier to find, the first one is not.

function CDPrepDirectory : string;
Returns the folder used by Windows to store files pending transfer to the CD.

In other words, copying files to this location will cause Windows to tell the user there are files waiting to be burned to the CD.  If you need a way to backup files to a CD, this may be one solution.

AFAIK, this won't work on Windows versions prior to XP Service Pack 2 in which case it will return an empty string.

If CDPrepDirectory <> '' then
  CopyThisFile('C:\MyProject\MyFile.txt', CDPrepDirectory+'MyFile.txt');

function WindowsRegisteredOrganizationName : string;
function WindowsRegisteredOwnerName : string;
These functions return the name or organization that the owner used when he or she registered their system.  The Owner Name will often be their full name, but it may also be something like "Registered Owner".

My experience has been that WindowsRegisteredOwnerName will return a usable value about 75% of the time, and WindowsRegisteredOrganizationName will return a value less than 10% of the time.  Business PC's seem to return a value less often than home systems, but your results will probably vary from mine.

function WindowsVersionName : string;
This returns the name of the Windows version.  For example, Windows 98 systems will return the string "Windows 98".

function WindowsDirectory : string;
function TempDirectory : string;
function DesktopDirectory : string;
function ProgramFilesDirectory : string;
function MyDocumentsDirectory : string;
These functions return the locations of the Windows, Temp, Desktop, Program Files and My Documents folders.

They will always have a trailing backslash ("\") even if the registry entry didn't supply one.  This allows you to append a filename without worrying about a backslash, like this:

CreateThisFile(DesktopDirectory + 'MyFile.txt');

The information is only retrieved from the registry once.  It is stored in local variables for subsequent calls to these functions.

Download MyInfo.pas  (6,182 bytes) -- Sept-17-2006.


function PxBuild()

This unit contains a procedure to easily create Paradox tables with optional index files.

Here is a sample usage:

    Success := PxBuild(Database1.Handle, 'Example1.db',
                       NewSItem('Account, N*',
                       NewSItem('Transaction, S*',
                       NewSItem('Name, A20+',
                       NewSItem('Amount, $',
                                nil))))
                       );

Each field must be defined by field name and type, followed by an optional asterisk ("*") and/or plus ("+"), to indicate a key field or index.

The NewSItem function is also included in this unit.  Some programmers may recognize it from the old Turbo Vision days.

Download PxBuildr.pas  (7,433 bytes) -- Jan-14-2002.


TEncryptionStream = class(TFileStream)

The primary benefit of TEncryptionStream is that it may be quickly substituted for a TFileStream, without having to change anything else in your programs.  The encryption is not world-class by any means (in fact, it's extremely weak), but it may be your only encryption option when using a third-party tool that works with streams.

It will perform a very simple encryption as it reads or writes the data.  It's a quick enhancement that keeps most users from prying without major hassles on your part.

You'll need to run this stream on your data (a simple demo program included with the .ZIP file may be used for this purpose).  Then replace any use of that file on TFileStream with TEncryptionStream.

I recommend that programmers who use this should change the value of the global constant DefaultEncryptionCode.  And if you want something a little more secure, you can rewrite the Encode and Decode methods.

You'll notice that the encryption is performed one byte at a time, and that this severely limits the degree of sophistication that may be possible.  But any serious method (like DES) would add more rules to how this stream may be used, and that wasn't my intent.

Download Encoders.zip  (1,839 bytes) -- Jan-12-2002.


Paradox Table File Recovery...

Paradox Specifications...

tvDMX for Turbo Pascal... (just in case anyone still uses that)


     

Return to main page

randybeck.com