StringList to Resource

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

Problem Description

There are situations where it would be convenient to incorporate a text file into the executable module of a program.  Doing so eliminates the chance that the text file would be accidentally deleted or modified. This program, StringListToResource, implements this ability by converting a text file to "resource" file.  The resource file may be embedded into the program at link time and converted back to a string list  by some simple code changes within the program.

Background & Techniques

Twice in recent weeks I have had occasion to work on programs which meet the conditions described above: requiring a fixed text file be read into the program each time it is executed.  One is Translations which helps translate program text to languages other than English.  It reads a file, "ISO639V1.txt",  which provides language names associated with the nearly 200 two-letter language code identifiers defined by ISO standard 639.1.  The other program is KeyCodes which displays the names associated with scan-codes generated when keyboard keys are pressed.   Text file "VKeys.txt" defines those associations.

Both of the text files listed above are included as samples in this distribution.  In order to  embed a text file as a resource we need to compile a resource script using the Borland Resource Compiler, brcc32,exe. This is a somewhat ancient DOS command line program making its usage somewhat inconvenient.   Our program:

  1. Solicits the name of the text file to be embedded,
  2. Allows the user to change the default resource type identifier, STRINGLIST, to another name if he chooses,
  3. Builds the resource script, (.rc), file, an invokes BRCC32.exe  which will build the .res resource file to be included in the program requiring the text.

The name of the selected text file becomes the base file name for the resource script file and the compiled resource file with the ".txt" text file extension replaced by  ".rc" and ".res" respectively.

 I have not yet figured out how to redirect any output messages from the resource compiler back to my program, so i settled for making sure that a new .res file is built before declaring success.  All I can recommend for now is to revert to using CMD to run brcc32.exe if problems arise. 

Once the RES file is built, we still need to retrieve it with the using program,  Rather than describing it here, refer to the KeyCodes program to see how to  it was accomplished.    

Running/Exploring the Program 

bullet Download source
bulletDownload  executable

Suggestions for Further Explorations

???
 
Original:  July 25, 2011

Modified:  February 18, 2016

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.